mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
* string.c (rb_hash_uint32, rb_hash_uint, rb_hash_start, rb_hash_end),
include/ruby/intern.h: add Murmurhash API. [ruby-dev:37784] * complex.c (nucomp_hash), array.c (rb_ary_hash), time.c (time_hash), string.c (rb_str_hsah), object.c (rb_obj_hash), range.c (range_hash), struct.c (rb_struct_hash), hash.c (rb_any_hash), rational.c (nurat_hash): use Murmurhash. [ruby-dev:37784] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a48f90b05b
commit
e722ad99d5
12 changed files with 117 additions and 30 deletions
11
struct.c
11
struct.c
|
@ -804,16 +804,17 @@ rb_struct_equal(VALUE s, VALUE s2)
|
|||
static VALUE
|
||||
rb_struct_hash(VALUE s)
|
||||
{
|
||||
long i, h;
|
||||
long i;
|
||||
unsigned h;
|
||||
VALUE n;
|
||||
|
||||
h = rb_hash(rb_obj_class(s));
|
||||
h = rb_hash_start(rb_hash(rb_obj_class(s)));
|
||||
for (i = 0; i < RSTRUCT_LEN(s); i++) {
|
||||
h = (h << 1) | (h<0 ? 1 : 0);
|
||||
n = rb_hash(RSTRUCT_PTR(s)[i]);
|
||||
h ^= NUM2LONG(n);
|
||||
h = rb_hash_uint(h, NUM2LONG(n));
|
||||
}
|
||||
return LONG2FIX(h);
|
||||
h = rb_hash_end(h);
|
||||
return INT2FIX(h);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue