/// GetIdentifierInfo - Used to reconstruct IdentifierInfo objects from the
/// PTH file.
- IdentifierInfo* GetIdentifierInfo(unsigned);
+ inline IdentifierInfo* GetIdentifierInfo(unsigned PersistentID) {
+ // Check if the IdentifierInfo has already been resolved.
+ if (IdentifierInfo* II = PerIDCache[PersistentID])
+ return II;
+ return LazilyCreateIdentifierInfo(PersistentID);
+ }
+ IdentifierInfo* LazilyCreateIdentifierInfo(unsigned PersistentID);
public:
~PTHManager();
return new PTHManager(File.take(), FL.take(), IData, PerIDCache,
SortedIdTable, NumIds);
}
-
-IdentifierInfo* PTHManager::GetIdentifierInfo(unsigned persistentID) {
-
- // Check if the IdentifierInfo has already been resolved.
- IdentifierInfo* II = PerIDCache[persistentID];
- if (II) return II;
-
+IdentifierInfo* PTHManager::LazilyCreateIdentifierInfo(unsigned PersistentID) {
// Look in the PTH file for the string data for the IdentifierInfo object.
- const unsigned char* TableEntry = IdDataTable + sizeof(uint32_t)*persistentID;
+ const unsigned char* TableEntry = IdDataTable + sizeof(uint32_t)*PersistentID;
const unsigned char* IDData =
(const unsigned char*)Buf->getBufferStart() + Read32(TableEntry);
assert(IDData < (const unsigned char*)Buf->getBufferEnd());
Alloc.Allocate<std::pair<IdentifierInfo,const unsigned char*> >();
Mem->second = IDData;
- II = new ((void*) Mem) IdentifierInfo(true);
+ IdentifierInfo *II = new ((void*) Mem) IdentifierInfo(true);
// Store the new IdentifierInfo in the cache.
- PerIDCache[persistentID] = II;
+ PerIDCache[PersistentID] = II;
return II;
}