From 2dec07424eaeade587740f1d2751986a36ea70f1 Mon Sep 17 00:00:00 2001 From: mame Date: Sat, 14 Feb 2009 19:55:34 +0000 Subject: * 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: http://svn.ruby-lang.org/repos/ruby/trunk@22317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- complex.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'complex.c') diff --git a/complex.c b/complex.c index 180e7d23c..ceb7b75f7 100644 --- a/complex.c +++ b/complex.c @@ -22,7 +22,7 @@ VALUE rb_cComplex; static ID id_abs, id_abs2, id_arg, id_cmp, id_conj, id_convert, - id_denominator, id_divmod, id_equal_p, id_expt, id_floor, id_hash, + id_denominator, id_divmod, id_equal_p, id_expt, id_floor, id_idiv, id_inspect, id_negate, id_numerator, id_polar, id_quo, id_real_p, id_to_f, id_to_i, id_to_r, id_to_s; @@ -153,15 +153,12 @@ f_sub(VALUE x, VALUE y) return rb_funcall(x, '-', 1, y); } -binop(xor, '^') - fun1(abs) fun1(abs2) fun1(arg) fun1(conj) fun1(denominator) fun1(floor) -fun1(hash) fun1(inspect) fun1(negate) fun1(numerator) @@ -857,8 +854,17 @@ nucomp_numerator(VALUE self) static VALUE nucomp_hash(VALUE self) { + long v, h[3]; + VALUE n; + get_dat1(self); - return f_xor(f_hash(dat->real), f_hash(dat->imag)); + h[0] = rb_hash(rb_obj_class(self)); + n = rb_hash(dat->real); + h[1] = NUM2LONG(n); + n = rb_hash(dat->imag); + h[2] = NUM2LONG(n); + v = rb_memhash(h, sizeof(h)); + return LONG2FIX(v); } static VALUE @@ -1384,7 +1390,6 @@ Init_Complex(void) id_equal_p = rb_intern("=="); id_expt = rb_intern("**"); id_floor = rb_intern("floor"); - id_hash = rb_intern("hash"); id_idiv = rb_intern("div"); id_inspect = rb_intern("inspect"); id_negate = rb_intern("-@"); -- cgit