Branch: Tag:

2011-04-05

2011-04-05 12:20:06 by Arne Goedeke <el@laramies.com>

mapping: use power of two hashtables and a mixing function instead of
modulo prime

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: stuff.c,v 1.23 2004/11/14 18:03:50 mast Exp $ + || $Id$   */      #include "global.h"
430:       return primes[y];   } +  + /* +  * This rounds an integer up to the next power of two. For x a power +  * of two, this will just return the same again. +  */ + unsigned INT32 find_next_power(unsigned INT32 x) + { +  x--; +  x |= x >> 1; +  x |= x >> 2; +  x |= x >> 4; +  x |= x >> 8; +  x |= x >> 16; +  x++; +  return x; + }