[llvm] r326625 - Make llvm::djbHash an inline function.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 2 14:00:38 PST 2018
Author: ruiu
Date: Fri Mar 2 14:00:38 2018
New Revision: 326625
URL: http://llvm.org/viewvc/llvm-project?rev=326625&view=rev
Log:
Make llvm::djbHash an inline function.
Differential Revision: https://reviews.llvm.org/D43644
Modified:
llvm/trunk/include/llvm/Support/DJB.h
llvm/trunk/lib/Support/DJB.cpp
Modified: llvm/trunk/include/llvm/Support/DJB.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DJB.h?rev=326625&r1=326624&r2=326625&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/DJB.h (original)
+++ llvm/trunk/include/llvm/Support/DJB.h Fri Mar 2 14:00:38 2018
@@ -19,7 +19,11 @@
namespace llvm {
/// The Bernstein hash function used by the DWARF accelerator tables.
-uint32_t djbHash(StringRef Buffer, uint32_t H = 5381);
+inline uint32_t djbHash(StringRef Buffer, uint32_t H = 5381) {
+ for (unsigned char C : Buffer.bytes())
+ H = (H << 5) + H + C;
+ return H;
+}
/// Computes the Bernstein hash after folding the input according to the Dwarf 5
/// standard case folding rules.
Modified: llvm/trunk/lib/Support/DJB.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/DJB.cpp?rev=326625&r1=326624&r2=326625&view=diff
==============================================================================
--- llvm/trunk/lib/Support/DJB.cpp (original)
+++ llvm/trunk/lib/Support/DJB.cpp Fri Mar 2 14:00:38 2018
@@ -19,16 +19,6 @@
using namespace llvm;
-static inline uint32_t djbHashChar(unsigned char C, uint32_t H) {
- return (H << 5) + H + C;
-}
-
-uint32_t llvm::djbHash(StringRef Buffer, uint32_t H) {
- for (unsigned char C : Buffer.bytes())
- H = djbHashChar(C, H);
- return H;
-}
-
static UTF32 chopOneUTF32(StringRef &Buffer) {
UTF32 C;
const UTF8 *const Begin8Const =
@@ -86,7 +76,7 @@ uint32_t llvm::caseFoldingDjbHash(String
// This is by far the most common case, so handle this specially.
if (C >= 'A' && C <= 'Z')
C = 'a' + (C - 'A'); // fold uppercase into lowercase
- H = djbHashChar(C, H);
+ H = (H << 5) + H + C;
Buffer = Buffer.drop_front();
continue;
}
More information about the llvm-commits
mailing list