[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
mjs
mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:27:09 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 53714aa1bacad94a1843e0b3ce002c8805b428ec
Author: mjs <mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Mar 4 02:09:44 2003 +0000
Reviewed by Richard.
- upgrade to new hash function in one spot that I missed:
* kwq/KWQString.mm:
(QString::hash): Use spiffy new hash algorithm.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3738 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 9140262..6894e0f 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,12 @@
+2003-03-03 Maciej Stachowiak <mjs at apple.com>
+
+ Reviewed by Richard.
+
+ - upgrade to new hash function in one spot that I missed:
+
+ * kwq/KWQString.mm:
+ (QString::hash): Use spiffy new hash algorithm.
+
2003-03-01 Maciej Stachowiak <mjs at apple.com>
Reviewed by Darin.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 9140262..6894e0f 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,12 @@
+2003-03-03 Maciej Stachowiak <mjs at apple.com>
+
+ Reviewed by Richard.
+
+ - upgrade to new hash function in one spot that I missed:
+
+ * kwq/KWQString.mm:
+ (QString::hash): Use spiffy new hash algorithm.
+
2003-03-01 Maciej Stachowiak <mjs at apple.com>
Reviewed by Darin.
diff --git a/WebCore/kwq/KWQString.mm b/WebCore/kwq/KWQString.mm
index 6ca39ba..c3fb30b 100644
--- a/WebCore/kwq/KWQString.mm
+++ b/WebCore/kwq/KWQString.mm
@@ -2538,28 +2538,57 @@ bool operator==(const QString &s1, const char *chs)
return chs[len] == '\0';
}
+// Golden ratio - arbitrary start value to avoid mapping all 0's to all 0's
+// or anything like that.
+const unsigned PHI = 0x9e3779b9U;
+
+// This hash algorithm comes from:
+// http://burtleburtle.net/bob/hash/hashfaq.html
+// http://burtleburtle.net/bob/hash/doobs.html
uint QString::hash() const
{
uint len = length();
- uint h = len;
+
+ uint h = PHI;
+ h += len;
+ h += (h << 10);
+ h ^= (h << 6);
+
if (len) {
uint prefixLength = len < 8 ? len : 8;
uint suffixPosition = len < 16 ? 8 : len - 8;
if (dataHandle[0]->_isAsciiValid) {
const char *s = ascii();
- for (uint i = 0; i < prefixLength; i++)
- h = 127 * h + (unsigned char)s[i];
- for (uint i = suffixPosition; i < len; i++)
- h = 127 * h + (unsigned char)s[i];
+ for (uint i = 0; i < prefixLength; i++) {
+ h += (unsigned char)s[i];
+ h += (h << 10);
+ h ^= (h << 6);
+ }
+ for (uint i = suffixPosition; i < len; i++) {
+ h += (unsigned char)s[i];
+ h += (h << 10);
+ h ^= (h << 6);
+ }
} else {
const QChar *s = unicode();
- for (uint i = 0; i < prefixLength; i++)
- h = 127 * h + s[i].unicode();
- for (uint i = suffixPosition; i < len; i++)
- h = 127 * h + s[i].unicode();
+ for (uint i = 0; i < prefixLength; i++) {
+ h += s[i].unicode();
+ h += (h << 10);
+ h ^= (h << 6);
+ }
+ for (uint i = suffixPosition; i < len; i++) {
+ h += s[i].unicode();
+ h += (h << 10);
+ h ^= (h << 6);
+ }
}
}
+
+ h += (h << 3);
+ h ^= (h >> 11);
+ h += (h << 15);
+
if (h == 0)
h = 0x80000000;
return h;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list