[PATCH] D43644: Make llvm::djbHash an inline function.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 2 14:05:32 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326625: Make llvm::djbHash an inline function. (authored by ruiu, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D43644?vs=135514&id=136848#toc
Repository:
rL LLVM
https://reviews.llvm.org/D43644
Files:
llvm/trunk/include/llvm/Support/DJB.h
llvm/trunk/lib/Support/DJB.cpp
Index: llvm/trunk/include/llvm/Support/DJB.h
===================================================================
--- llvm/trunk/include/llvm/Support/DJB.h
+++ llvm/trunk/include/llvm/Support/DJB.h
@@ -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.
Index: llvm/trunk/lib/Support/DJB.cpp
===================================================================
--- llvm/trunk/lib/Support/DJB.cpp
+++ llvm/trunk/lib/Support/DJB.cpp
@@ -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 @@
// 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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43644.136848.patch
Type: text/x-patch
Size: 1498 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180302/00636b11/attachment.bin>
More information about the llvm-commits
mailing list