Move the hash function to using and taking a StringRef.
authorEric Christopher <echristo@apple.com>
Mon, 7 Nov 2011 21:49:35 +0000 (21:49 +0000)
committerEric Christopher <echristo@apple.com>
Mon, 7 Nov 2011 21:49:35 +0000 (21:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144024 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/DwarfAccelTable.h

index 4fc6118274e3d277a37b5b9dde0a9405c6338b47..a0f64f040b4defab1b60afa617e9cfbcf87b9d02 100644 (file)
@@ -69,10 +69,10 @@ class DwarfAccelTable {
     eHashFunctionDJB = 0u
   };
 
-  static uint32_t HashDJB (const char *s) {
+  static uint32_t HashDJB (StringRef Str) {
     uint32_t h = 5381;
-    for (unsigned char c = *s; c; c = *++s)
-      h = ((h << 5) + h) + c;
+    for (unsigned i = 0, e = Str.size(); i != e; ++i)
+      h = ((h << 5) + h) + Str[i];
     return h;
   }
 
@@ -190,7 +190,7 @@ public:
     MCSymbol *Sym;
     std::vector<uint32_t> DIEOffsets; // offsets
     HashData(StringRef S) : Str(S) {
-      HashValue = DwarfAccelTable::HashDJB(S.str().c_str());
+      HashValue = DwarfAccelTable::HashDJB(S);
     }
     void addOffset(uint32_t off) { DIEOffsets.push_back(off); }
     #ifndef NDEBUG