pike.git / src / stuff.c

version» Context lines:

pike.git/src/stuff.c:1:   /*\   ||| This file is part of Pike. For copyright information see COPYRIGHT.   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/      /* -  * $Id: stuff.c,v 1.16 2002/01/16 02:54:20 nilsson Exp $ +  * $Id: stuff.c,v 1.17 2002/04/30 01:06:08 mast Exp $    */   #include "global.h"   #include "stuff.h"   #include "stralloc.h"      /* Not all of these are primes, but they should be adequate */   PMOD_EXPORT INT32 hashprimes[32] =   {    31, /* ~ 2^0 = 1 */    31, /* ~ 2^1 = 2 */
pike.git/src/stuff.c:146:    }    }    return x;   }      /* This routine basically finds a prime number    * which is larger than 'x'    */   unsigned long find_good_hash_size(unsigned long num)   { -  static unsigned long primes[864] = +  static const unsigned long primes[] =    {    37UL, 37UL, 37UL, 37UL,    37UL, 37UL, 41UL, 41UL,    41UL, 41UL, 43UL, 43UL,    47UL, 47UL, 47UL, 47UL,    53UL, 53UL, 53UL, 53UL,    53UL, 53UL, 59UL, 59UL,    59UL, 59UL, 59UL, 59UL,    61UL, 61UL, 67UL, 67UL,    67UL, 67UL, 71UL, 71UL,
pike.git/src/stuff.c:363:    1778384921UL, 1811939329UL, 1845493777UL, 1879048201UL,    1912602623UL, 1946157079UL, 1979711497UL, 2013265921UL,    2046820351UL, 2080374797UL, 2113929217UL, 2147483647UL,    2214592529UL, 2281701377UL, 2348810279UL, 2415919109UL,    2483027969UL, 2550136861UL, 2617245707UL, 2684354591UL,    2751463433UL, 2818572287UL, 2885681153UL, 2952790033UL,    3019898923UL, 3087007751UL, 3154116619UL, 3221225473UL,    3288334369UL, 3355443229UL, 3422552069UL, 3489660929UL,    3556769813UL, 3623878669UL, 3690987527UL, 3758096383UL,    3825205247UL, 3892314113UL, 3959422979UL, 4026531853UL, -  4093640729UL, 4160749601UL, 4227858463UL, 4294967311UL +  4093640729UL, 4160749601UL, 4227858463UL    };    int shift=16;    unsigned long cmp=0x1fffff;    unsigned long x=num; -  int y=0; +  unsigned int y=0;       if(x<32)    { -  static unsigned long lowprimes[32]={ +  static const unsigned long lowprimes[32]={    1,1,2,3,    5,5,7,7,    11,11,11,11,    13,13,17,17,    17,17,19,19,    23,23,23,23,    29,29,29,29,    29,29,31,31    };    return lowprimes[x];
pike.git/src/stuff.c:401:    }    shift>>=1;    cmp>>=shift;    }       /* For really large numbers, produce a number which is not    * a prime, but hopefully good for hash tables, although I    * seriously doubt anybody will use hashtables larger than    * 1<<32 entries... /Hubbe    */ -  if(x>63) return num|7; +  y = (y<<5)|(x&31); +  if(y >= NELEM(primes)) return num|7;    -  return primes[(y<<5)|(x&31)]; +  return primes[y];   }