forked from apache/apr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@61375 13f79535-47bb-0310-9956-ffa450edef68
- Loading branch information
Showing
1 changed file
with
13 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,11 +222,17 @@ static apr_hash_entry_t **find_entry(apr_hash_t *ht, | |
klen = strlen(key); | ||
|
||
/* | ||
* This is Daniel J. Bernstein's popular `times 33' hash function | ||
* as posted by him years ago on comp.lang.c and used by perl. | ||
* This is one of the best known hash functions for strings | ||
* because it is both computed very fast and distributes very | ||
* well. | ||
* This is the popular `times 33' hash algorithm which is used by | ||
* perl and also appears in Berkeley DB. This is one of the best | ||
* known hash functions for strings because it is both computed | ||
* very fast and distributes very well. | ||
* | ||
* The originator may be Dan Bernstein but the code in Berkeley DB | ||
* cites Chris Torek as the source. The best citation I have found | ||
* is "Chris Torek, Hash function for text in C, Usenet message | ||
* <[email protected]> in comp.lang.c , October, 1990." in Rich | ||
* Salz's USENIX 1992 paper about INN which can be found at | ||
* <http://citeseer.nj.nec.com/salz92internetnews.html>. | ||
* | ||
* The magic of number 33, i.e. why it works better than many other | ||
* constants, prime or not, has never been adequately explained by | ||
|
@@ -248,9 +254,8 @@ static apr_hash_entry_t **find_entry(apr_hash_t *ht, | |
* operation can be replaced by a faster operation based on just one | ||
* shift plus either a single addition or subtraction operation. And | ||
* because a hash function has to both distribute good _and_ has to | ||
* be very fast to compute, those few numbers should be preferred | ||
* and seems to be the reason why Daniel J. Bernstein also preferred | ||
* it. | ||
* be very fast to compute, those few numbers should be preferred. | ||
* | ||
* -- Ralf S. Engelschall <[email protected]> | ||
*/ | ||
hash = 0; | ||
|