diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-03-09 23:43:07 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-03-09 23:43:07 +0000 |
commit | d43b333be82438102ff4c459b1fb5dfb764e5f0d (patch) | |
tree | adfe7052a4816c672a924d712c083d7c548c298e /include/clang/Basic/IdentifierTable.h | |
parent | 43b7bd31f906f4020090ffb4f64a09d35fb13680 (diff) |
Reapply r66316, it got accidentally reverted in r66317.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66506 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/IdentifierTable.h')
-rw-r--r-- | include/clang/Basic/IdentifierTable.h | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index 7630811f21..df0200f1e7 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -267,24 +267,27 @@ public: 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; } |