Speed up the rebuildCachedFields method, which is very often used for generic types.