[cfe-commits] r66506 - /cfe/trunk/include/clang/Basic/IdentifierTable.h
Daniel Dunbar
daniel at zuster.org
Mon Mar 9 16:43:07 PDT 2009
Author: ddunbar
Date: Mon Mar 9 18:43:07 2009
New Revision: 66506
URL: http://llvm.org/viewvc/llvm-project?rev=66506&view=rev
Log:
Reapply r66316, it got accidentally reverted in r66317.
Modified:
cfe/trunk/include/clang/Basic/IdentifierTable.h
Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=66506&r1=66505&r2=66506&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/IdentifierTable.h (original)
+++ cfe/trunk/include/clang/Basic/IdentifierTable.h Mon Mar 9 18:43:07 2009
@@ -267,24 +267,27 @@
HashTable.GetOrCreateValue(NameStart, NameEnd);
IdentifierInfo *II = Entry.getValue();
+ if (II) return *II;
- if (!II) {
- while (1) {
- if (ExternalLookup) {
- II = ExternalLookup->get(NameStart, NameEnd);
- if (II) break;
- }
-
- void *Mem = getAllocator().Allocate<IdentifierInfo>();
- II = new (Mem) IdentifierInfo();
- break;
+ // No entry; if we have an external lookup, look there first.
+ if (ExternalLookup) {
+ II = ExternalLookup->get(NameStart, NameEnd);
+ if (II) {
+ // Cache in the StringMap for subsequent lookups.
+ Entry.setValue(II);
+ return *II;
}
-
- Entry.setValue(II);
- II->Entry = &Entry;
}
- assert(II->Entry != 0);
+ // Lookups failed, make a new IdentifierInfo.
+ void *Mem = getAllocator().Allocate<IdentifierInfo>();
+ II = new (Mem) IdentifierInfo();
+ Entry.setValue(II);
+
+ // Make sure getName() knows how to find the IdentifierInfo
+ // contents.
+ II->Entry = &Entry;
+
return *II;
}
More information about the cfe-commits
mailing list