httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@locus.apache.org
Subject cvs commit: apache-2.0/src/lib/apr/lib apr_hash.c
Date Tue, 18 Jul 2000 23:39:02 GMT
fanf        00/07/18 16:39:02

  Modified:    src/lib/apr/lib apr_hash.c
  Log:
  Restore the reference to perl's use of DJB's hash function;
  Fix the name of the chi^2 distribution;
  Let the compiler decide how to multiply by 33.
  
  Revision  Changes    Path
  1.9       +7 -7      apache-2.0/src/lib/apr/lib/apr_hash.c
  
  Index: apr_hash.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/lib/apr_hash.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -u -r1.8 -r1.9
  --- apr_hash.c	2000/07/14 19:55:50	1.8
  +++ apr_hash.c	2000/07/18 23:39:01	1.9
  @@ -220,10 +220,10 @@
   
       /*
        * This is Daniel J. Bernstein's popular `times 33' hash function
  -     * as posted by him years ago on comp.lang.c. It basically uses a
  -     * function like ``hash(i) = hash(i-1) * 33 + str[i]''. This is one
  -     * of the best known hash functions for strings. Because it is both
  -     * computed very fast and distributes very well.
  +     * 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.
        *
        * The magic of number 33, i.e. why it works better than many other
        * constants, prime or not, has never been adequately explained by
  @@ -235,10 +235,10 @@
        * They all distribute in an acceptable way and this way fill a hash
        * table with an average percent of approx. 86%.
        *
  -     * If one compares the Chi/2 values of the variants (see
  +     * If one compares the chi^2 values of the variants (see
        * Bob Jenkins ``Hashing Frequently Asked Questions'' at
        * http://burtleburtle.net/bob/hash/hashfaq.html for a description
  -     * of Chi/2), the number 33 not even has the best value. But the
  +     * of chi^2), the number 33 not even has the best value. But the
        * number 33 and a few other equally good numbers like 17, 31, 63,
        * 127 and 129 have nevertheless a great advantage to the remaining
        * numbers in the large set of possible multipliers: their multiply
  @@ -252,7 +252,7 @@
        */
       hash = 0;
       for (p = key, i = klen; i; i--, p++)
  -	hash = ((hash << 5) + hash) + *p;
  +	hash = hash * 33 + *p;
       
       /* scan linked list */
       for (hep = &ht->array[hash & ht->max], he = *hep;
  
  
  

Mime
View raw message