Removed pointless 8-char optimization.
Now it is more useful for this to hash identically as in Java. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5753 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -44,10 +44,9 @@ public class StringUtil
|
|||||||
{
|
{
|
||||||
var code :int = 0;
|
var code :int = 0;
|
||||||
if (str != null) {
|
if (str != null) {
|
||||||
// sample at most 8 chars
|
// hash identically to Java's String.hashCode(), for various reasons
|
||||||
var lastChar :int = Math.min(8, str.length);
|
for (var ii :int = 0; ii < str.length; ii++) {
|
||||||
for (var ii :int = 0; ii < lastChar; ii++) {
|
code = 31 * code + str.charCodeAt(ii);
|
||||||
code = code * 31 + str.charCodeAt(ii);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
|||||||
Reference in New Issue
Block a user