diff options
author | Steve Naroff <snaroff@apple.com> | 2007-09-19 16:18:46 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2007-09-19 16:18:46 +0000 |
commit | 21d5a95b8f50be3e0fdd8c53f92fc201f665a4b4 (patch) | |
tree | 5e88ff7c5b86ae59b842d2582d48210dfbdee089 /Lex/IdentifierTable.cpp | |
parent | 2cc62aad7d4cb604517c6e9decb79596605a2df0 (diff) |
Remove SelectorTable/SelectorInfo, simply store all selectors in the central IdentifierTable.
Rationale:
We currently have a separate table to unique ObjC selectors. Since I don't need all the instance data in IdentifierInfo, I thought this would save space (and make more sense conceptually).
It turns out the cost of having duplicate entries for unary selectors (i.e. names without colons) outweighs the cost difference between the IdentifierInfo & SelectorInfo structures. Here is the data:
Two tables:
*** Selector/Identifier Stats:
# Selectors/Identifiers: 51635
Bytes allocated: 1999824
One table:
*** Identifier Table Stats:
# Identifiers: 49500
Bytes allocated: 1990316
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42139 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Lex/IdentifierTable.cpp')
-rw-r--r-- | Lex/IdentifierTable.cpp | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/Lex/IdentifierTable.cpp b/Lex/IdentifierTable.cpp index c1c00d232b..d3faeb58db 100644 --- a/Lex/IdentifierTable.cpp +++ b/Lex/IdentifierTable.cpp @@ -209,34 +209,3 @@ void IdentifierTable::PrintStats() const { // Compute statistics about the memory allocated for identifiers. HashTable.getAllocator().PrintStats(); } - -/// PrintStats - Print statistics about how well the identifier table is doing -/// at hashing identifiers. -void SelectorTable::PrintStats() const { - unsigned NumBuckets = HashTable.getNumBuckets(); - unsigned NumIdentifiers = HashTable.getNumItems(); - unsigned NumEmptyBuckets = NumBuckets-NumIdentifiers; - unsigned AverageIdentifierSize = 0; - unsigned MaxIdentifierLength = 0; - - // TODO: Figure out maximum times an identifier had to probe for -stats. - for (llvm::StringMap<SelectorInfo, llvm::BumpPtrAllocator>::const_iterator - I = HashTable.begin(), E = HashTable.end(); I != E; ++I) { - unsigned IdLen = I->getKeyLength(); - AverageIdentifierSize += IdLen; - if (MaxIdentifierLength < IdLen) - MaxIdentifierLength = IdLen; - } - - fprintf(stderr, "\n*** Selector Table Stats:\n"); - fprintf(stderr, "# Selectors: %d\n", NumIdentifiers); - fprintf(stderr, "# Empty Buckets: %d\n", NumEmptyBuckets); - fprintf(stderr, "Hash density (#selectors per bucket): %f\n", - NumIdentifiers/(double)NumBuckets); - fprintf(stderr, "Ave selector length: %f\n", - (AverageIdentifierSize/(double)NumIdentifiers)); - fprintf(stderr, "Max selector length: %d\n", MaxIdentifierLength); - - // Compute statistics about the memory allocated for identifiers. - HashTable.getAllocator().PrintStats(); -} |