[llvm-commits] [llvm] r162882 - /llvm/trunk/include/llvm/ADT/StringExtras.h
Will Dietz
wdietz2 at illinois.edu
Wed Aug 29 17:30:21 PDT 2012
Author: wdietz2
Date: Wed Aug 29 19:30:21 2012
New Revision: 162882
URL: http://llvm.org/viewvc/llvm-project?rev=162882&view=rev
Log:
Fix HashString's Bernstein hash to use unsigned chars, as is usually done.
Changes the hash result for strings containing characters
with values >= 128, such as UTF8 strings (not normal ASCII).
Changed mostly so we match other implementations.
Modified:
llvm/trunk/include/llvm/ADT/StringExtras.h
Modified: llvm/trunk/include/llvm/ADT/StringExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringExtras.h?rev=162882&r1=162881&r2=162882&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/StringExtras.h (original)
+++ llvm/trunk/include/llvm/ADT/StringExtras.h Wed Aug 29 19:30:21 2012
@@ -125,7 +125,7 @@
// X*33+c -> X*33^c
static inline unsigned HashString(StringRef Str, unsigned Result = 0) {
for (unsigned i = 0, e = Str.size(); i != e; ++i)
- Result = Result * 33 + Str[i];
+ Result = Result * 33 + (unsigned char)Str[i];
return Result;
}
More information about the llvm-commits
mailing list