[cfe-commits] r39038 - /cfe/cfe/trunk/Lex/IdentifierTable.cpp

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:27:02 PDT 2007


Author: sabre
Date: Wed Jul 11 11:27:02 2007
New Revision: 39038

URL: http://llvm.org/viewvc/llvm-project?rev=39038&view=rev
Log:
Switch to using a bitwise and instead of modulus.

Modified:
    cfe/cfe/trunk/Lex/IdentifierTable.cpp

Modified: cfe/cfe/trunk/Lex/IdentifierTable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/IdentifierTable.cpp?rev=39038&r1=39037&r2=39038&view=diff

==============================================================================
--- cfe/cfe/trunk/Lex/IdentifierTable.cpp (original)
+++ cfe/cfe/trunk/Lex/IdentifierTable.cpp Wed Jul 11 11:27:02 2007
@@ -125,6 +125,8 @@
 };
 
 // FIXME: start hashtablesize off at 8K entries, GROW when density gets to 3.
+/// HASH_TABLE_SIZE - The current size of the hash table.  Note that this must
+/// always be a power of two!
 static unsigned HASH_TABLE_SIZE = 8096;
 
 IdentifierTable::IdentifierTable(const LangOptions &LangOpts) {
@@ -177,7 +179,7 @@
                                      const char *NameEnd) {
   IdentifierBucket **TableArray = (IdentifierBucket**)TheTable;
 
-  unsigned Hash = HashString(NameStart, NameEnd) % HASH_TABLE_SIZE;
+  unsigned Hash = HashString(NameStart, NameEnd) & (HASH_TABLE_SIZE-1);
   unsigned Length = NameEnd-NameStart;
   
   IdentifierBucket *IdentHead = TableArray[Hash];





More information about the cfe-commits mailing list