File: x31hash.c

package info (click to toggle)
entity 0.7.2-6
  • links: PTS
  • area: main
  • in suites: woody
  • size: 5,352 kB
  • ctags: 5,272
  • sloc: ansic: 61,707; sh: 7,921; makefile: 732; perl: 399
file content (25 lines) | stat: -rw-r--r-- 564 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* This was taken from the gtk-devel mailing list.  This hash will probly be put in
 * glib as the standard for next version.  It's apparently almost 2x faster and has
 * better distribution than the native glib hash */

/* In message: 

From: Karl Nelson <kenelson@ece.ucdavis.edu>
Subject: Re: g_str_hash
Date: Fri, 11 Feb 2000 15:36:55 -0800
To: gtk-devel-list@redhat.com

*/

#include <glib.h>

guint 
x31_hash (gconstpointer v)
{
   const char *p;
   guint h=0;
   for (p = (const char*) v; *p != '\0'; p += 1) 
     h = ( h << 5 ) - h  + *p;

   return h;
}