summaryrefslogtreecommitdiff
path: root/src/qhash.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2010-04-12 04:57:02 (GMT)
committerMarius Kintel <marius@kintel.net>2010-10-31 00:42:35 (GMT)
commit1caf80e561819832092e67bd15ceba5d6f9a02f8 (patch)
treeac144b7659840529155c762794508bea018b2be3 /src/qhash.cc
parente8e213b3c9ce0580045ea6e7e86b00ab41d4c58b (diff)
Added CSGTextCache for experimenting with cache-tree organization
Diffstat (limited to 'src/qhash.cc')
-rw-r--r--src/qhash.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/qhash.cc b/src/qhash.cc
new file mode 100644
index 0000000..cec9adf
--- /dev/null
+++ b/src/qhash.cc
@@ -0,0 +1,19 @@
+#include "myqhash.h"
+
+static uint hash(const uchar *p, int n)
+{
+ uint h = 0;
+ uint g;
+
+ while (n--) {
+ h = (h << 4) + *p++;
+ if ((g = (h & 0xf0000000)) != 0)
+ h ^= g >> 23;
+ h &= ~g;
+ }
+ return h;
+}
+
+uint qHash(const std::string &str) {
+ return hash(reinterpret_cast<const uchar *>(str.c_str()), str.length());
+}
contact: Jan Huwald // Impressum