@@ -201,22 +201,25 @@ TypeRefBuilder::getFieldTypeInfo(const TypeRef *TR) {
201
201
if (Found != FieldTypeInfoCache.end ())
202
202
return Found->second ;
203
203
204
- // On failure, fill out the cache with everything we know about.
205
- std::vector<std::pair<std::string, const TypeRef *>> Fields;
206
- for (auto &Info : ReflectionInfos) {
204
+ // On failure, fill out the cache, ReflectionInfo by ReflectionInfo,
205
+ // until we find the field desciptor we're looking for.
206
+ while (FirstUnprocessedReflectionInfoIndex < ReflectionInfos.size ()) {
207
+ auto &Info = ReflectionInfos[FirstUnprocessedReflectionInfoIndex];
207
208
for (auto FD : Info.Field ) {
208
209
if (!FD->hasMangledTypeName ())
209
210
continue ;
210
211
auto CandidateMangledName = readTypeRef (FD, FD->MangledTypeName );
211
212
if (auto NormalizedName = normalizeReflectionName (CandidateMangledName))
212
213
FieldTypeInfoCache[*NormalizedName] = FD;
213
214
}
214
- }
215
215
216
- // We've filled the cache with everything we know about now. Try the cache again.
217
- Found = FieldTypeInfoCache.find (MangledName);
218
- if (Found != FieldTypeInfoCache.end ())
219
- return Found->second ;
216
+ // Since we're done with the current ReflectionInfo, increment early in
217
+ // case we get a cache hit.
218
+ ++FirstUnprocessedReflectionInfoIndex;
219
+ Found = FieldTypeInfoCache.find (MangledName);
220
+ if (Found != FieldTypeInfoCache.end ())
221
+ return Found->second ;
222
+ }
220
223
221
224
return nullptr ;
222
225
}
0 commit comments