mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
optimize StringMap::clear
llvm-svn: 53009
This commit is contained in:
parent
06545d1c4a
commit
441571cc05
@ -335,8 +335,16 @@ public:
|
||||
|
||||
// clear - Empties out the StringMap
|
||||
void clear() {
|
||||
while (!empty())
|
||||
erase(begin());
|
||||
if (empty()) return;
|
||||
|
||||
// Zap all values, resetting the keys back to non-present (not tombstone),
|
||||
// which is safe because we're removing all elements.
|
||||
for (ItemBucket *I = TheTable, *E = TheTable+NumBuckets; I != E; ++I) {
|
||||
if (I->Item && I->Item != getTombstoneVal()) {
|
||||
static_cast<MapEntryTy*>(I->Item)->Destroy(Allocator);
|
||||
I->Item = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// GetOrCreateValue - Look up the specified key in the table. If a value
|
||||
@ -398,10 +406,7 @@ public:
|
||||
}
|
||||
|
||||
~StringMap() {
|
||||
for (ItemBucket *I = TheTable, *E = TheTable+NumBuckets; I != E; ++I) {
|
||||
if (I->Item && I->Item != getTombstoneVal())
|
||||
static_cast<MapEntryTy*>(I->Item)->Destroy(Allocator);
|
||||
}
|
||||
clear();
|
||||
free(TheTable);
|
||||
}
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user