You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rs...@locus.apache.org on 2000/07/14 22:01:56 UTC

cvs commit: apache-1.3/src/modules/standard mod_rewrite.c

rse         00/07/14 13:01:55

  Modified:    src/modules/standard mod_rewrite.c
  Log:
  Replace this unknown hash function someone contributed with the classical DJB
  times 33 hash (using XOR instead of ADD).  This hash is better understood and
  is faster. Also because in the old function the "& 0xff" was not necessary and
  just slowed down processing.
  
  Revision  Changes    Path
  1.158     +2 -2      apache-1.3/src/modules/standard/mod_rewrite.c
  
  Index: mod_rewrite.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v
  retrieving revision 1.157
  retrieving revision 1.158
  diff -u -r1.157 -r1.158
  --- mod_rewrite.c	2000/06/01 23:42:28	1.157
  +++ mod_rewrite.c	2000/07/14 20:01:55	1.158
  @@ -3856,8 +3856,8 @@
       char *p;
   
       n = 0;
  -    for (p=key; *p != '\0'; ++p) {
  -        n = n * 53711 + 134561 + (unsigned)(*p & 0xff);
  +    for (p = key; *p != '\0'; p++) {
  +        n = ((n << 5) + n) ^ (unsigned long)(*p++);
       }
   
       return (int)(n % CACHE_TLB_ROWS);
  
  
  

Re: cvs commit: apache-1.3/src/modules/standard mod_rewrite.c

Posted by Greg Stein <gs...@lyra.org>.
On Wed, Jul 19, 2000 at 12:21:35AM +0100, Tony Finch wrote:
> rse@locus.apache.org wrote:
> >
> >  Replace this unknown hash function someone contributed with the classical DJB
> >  times 33 hash (using XOR instead of ADD).
> 
> Uh, doesn't this reduce the amount that the bits get mixed up?

I'm with Tony on this one. XOR can flip a bit, but it has no "carry" to
monkey up higher-order bits.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

Re: cvs commit: apache-1.3/src/modules/standard mod_rewrite.c

Posted by Tony Finch <do...@dotat.at>.
rse@locus.apache.org wrote:
>
>  Replace this unknown hash function someone contributed with the classical DJB
>  times 33 hash (using XOR instead of ADD).

Uh, doesn't this reduce the amount that the bits get mixed up?

Tony.
-- 
f.a.n.finch    fanf@covalent.net    dot@dotat.at
318 butterfly appliqu�s on the sliding glass door of doom