From b9ad17593511a6ea513c237bd4efd760c9fb762b Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 26 Feb 2018 11:30:13 +0000 Subject: [Support] Replace HashString with djbHash. This removes the HashString function from StringExtraces and replaces its uses with calls to djbHash from DJB.h This is *almost* NFC. While the algorithm is identical, the djbHash implementation in StringExtras used 0 as its seed while the implementation in DJB uses 5381. The latter has been shown to result in less collisions and improved avalanching. https://reviews.llvm.org/D43615 (cherry picked from commit 77f7f965bc9499a9ae768a296ca5a1f7347d1d2c) llvm-svn: 326081 --- clang/lib/Frontend/CacheTokens.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'clang/lib/Frontend/CacheTokens.cpp') diff --git a/clang/lib/Frontend/CacheTokens.cpp b/clang/lib/Frontend/CacheTokens.cpp index 851ea25e9b1..f3569edc695 100644 --- a/clang/lib/Frontend/CacheTokens.cpp +++ b/clang/lib/Frontend/CacheTokens.cpp @@ -21,8 +21,8 @@ #include "clang/Lex/Lexer.h" #include "clang/Lex/PTHManager.h" #include "clang/Lex/Preprocessor.h" -#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringMap.h" +#include "llvm/Support/DJB.h" #include "llvm/Support/EndianStream.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" @@ -128,7 +128,7 @@ public: typedef unsigned offset_type; static hash_value_type ComputeHash(PTHEntryKeyVariant V) { - return llvm::HashString(V.getString()); + return llvm::djbHash(V.getString()); } static std::pair @@ -625,7 +625,7 @@ public: typedef unsigned offset_type; static hash_value_type ComputeHash(PTHIdKey* key) { - return llvm::HashString(key->II->getName()); + return llvm::djbHash(key->II->getName()); } static std::pair -- cgit v1.2.3