summaryrefslogtreecommitdiff
path: root/src/VBox/Runtime/common/string/strspace.cpp
diff options
context:
space:
mode:
authorFelix Geyer <debfx-pkg@fobos.de>2011-07-29 17:55:18 +0200
committerFelix Geyer <debfx-pkg@fobos.de>2011-07-29 17:55:18 +0200
commitcba113ca2826bc4814be2f69a7704c865a37d4ea (patch)
tree511123b10dd1e58e56958520534f5c50e6f570fc /src/VBox/Runtime/common/string/strspace.cpp
parent6a16f6900dd884e07125b51c9625f6be0a1f9b70 (diff)
downloadvirtualbox-cba113ca2826bc4814be2f69a7704c865a37d4ea.tar.gz
Imported Upstream version 4.1.0-dfsgupstream/4.1.0-dfsg
Diffstat (limited to 'src/VBox/Runtime/common/string/strspace.cpp')
-rw-r--r--src/VBox/Runtime/common/string/strspace.cpp42
1 files changed, 3 insertions, 39 deletions
diff --git a/src/VBox/Runtime/common/string/strspace.cpp b/src/VBox/Runtime/common/string/strspace.cpp
index 561db74c3..1c8b4655f 100644
--- a/src/VBox/Runtime/common/string/strspace.cpp
+++ b/src/VBox/Runtime/common/string/strspace.cpp
@@ -1,4 +1,4 @@
-/* $Id: strspace.cpp $ */
+/* $Id: strspace.cpp 36597 2011-04-06 19:46:15Z vboxsync $ */
/** @file
* IPRT - Unique String Spaces.
*/
@@ -32,6 +32,7 @@
#include "internal/iprt.h"
#include <iprt/assert.h>
+#include "internal/strhash.h"
/*******************************************************************************
@@ -40,6 +41,7 @@
/*
* AVL configuration.
*/
+#define KAVL_DECL(a_Type) static a_Type
#define KAVL_FN(a) rtstrspace##a
#define KAVL_MAX_STACK 27 /* Up to 2^24 nodes. */
#define KAVL_EQUAL_ALLOWED 1
@@ -72,44 +74,6 @@
-/* sdbm:
- This algorithm was created for sdbm (a public-domain reimplementation of
- ndbm) database library. it was found to do well in scrambling bits,
- causing better distribution of the keys and fewer splits. it also happens
- to be a good general hashing function with good distribution. the actual
- function is hash(i) = hash(i - 1) * 65599 + str[i]; what is included below
- is the faster version used in gawk. [there is even a faster, duff-device
- version] the magic constant 65599 was picked out of thin air while
- experimenting with different constants, and turns out to be a prime.
- this is one of the algorithms used in berkeley db (see sleepycat) and
- elsewhere. */
-DECLINLINE(uint32_t) sdbm(const char *str, size_t *pcch)
-{
- uint8_t *pu8 = (uint8_t *)str;
- uint32_t hash = 0;
- int c;
-
- while ((c = *pu8++))
- hash = c + (hash << 6) + (hash << 16) - hash;
-
- *pcch = (uintptr_t)pu8 - (uintptr_t)str - 1;
- return hash;
-}
-
-DECLINLINE(uint32_t) sdbmN(const char *str, size_t cchMax, size_t *pcch)
-{
- uint8_t *pu8 = (uint8_t *)str;
- uint32_t hash = 0;
- int c;
-
- while ((c = *pu8++) && cchMax-- > 0)
- hash = c + (hash << 6) + (hash << 16) - hash;
-
- *pcch = (uintptr_t)pu8 - (uintptr_t)str - 1;
- return hash;
-}
-
-
/**
* Inserts a string into a unique string space.
*