Created
December 4, 2009 01:03
-
-
Save arya/248747 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int | |
rb_str_hash(str) | |
VALUE str; | |
{ | |
register long len = RSTRING(str)->len; | |
register char *p = RSTRING(str)->ptr; | |
register int key = 0; | |
#if defined(HASH_ELFHASH) | |
register unsigned int g; | |
while (len--) { | |
key = (key << 4) + *p++; | |
if (g = key & 0xF0000000) | |
key ^= g >> 24; | |
key &= ~g; | |
} | |
#elif defined(HASH_PERL) | |
while (len--) { | |
key += *p++; | |
key += (key << 10); | |
key ^= (key >> 6); | |
} | |
key += (key << 3); | |
key ^= (key >> 11); | |
key += (key << 15); | |
#else | |
while (len--) { | |
key = key*65599 + *p; | |
p++; | |
} | |
key = key + (key>>5); | |
#endif | |
return key; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment