summaryrefslogtreecommitdiff
path: root/complex.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-14 19:55:34 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-14 19:55:34 +0000
commite722ad99d5b0e6a9bb0249ff3d9c8cce28d3204e (patch)
tree704a4bf758367e8c8b7100dd0cb2c5e8dd26c6b9 /complex.c
parenta48f90b05b654cc98727a91c5fd9952c5a86221c (diff)
downloadbundler-e722ad99d5b0e6a9bb0249ff3d9c8cce28d3204e.tar.gz
* 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
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/complex.c b/complex.c
index 180e7d23c9..ceb7b75f78 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("-@");