summaryrefslogtreecommitdiffstats
path: root/rational.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
commit2dec07424eaeade587740f1d2751986a36ea70f1 (patch)
tree704a4bf758367e8c8b7100dd0cb2c5e8dd26c6b9 /rational.c
parent603e226d2dbffd3a91bbcf47775e8137a9889ff2 (diff)
downloadruby-2dec07424eaeade587740f1d2751986a36ea70f1.tar.gz
ruby-2dec07424eaeade587740f1d2751986a36ea70f1.tar.xz
ruby-2dec07424eaeade587740f1d2751986a36ea70f1.zip
* 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
Diffstat (limited to 'rational.c')
-rw-r--r--rational.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/rational.c b/rational.c
index c90949377..9a2c23bfa 100644
--- a/rational.c
+++ b/rational.c
@@ -27,7 +27,7 @@
VALUE rb_cRational;
static ID id_abs, id_cmp, id_convert, id_equal_p, id_expt, id_floor,
- id_hash, id_idiv, id_inspect, id_integer_p, id_negate, id_to_f,
+ id_idiv, id_inspect, id_integer_p, id_negate, id_to_f,
id_to_i, id_to_s, id_truncate;
#define f_boolcast(x) ((x) ? Qtrue : Qfalse)
@@ -135,11 +135,8 @@ f_sub(VALUE x, VALUE y)
return rb_funcall(x, '-', 1, y);
}
-binop(xor, '^')
-
fun1(abs)
fun1(floor)
-fun1(hash)
fun1(inspect)
fun1(integer_p)
fun1(negate)
@@ -1161,8 +1158,17 @@ nurat_to_r(VALUE self)
static VALUE
nurat_hash(VALUE self)
{
+ long v, h[3];
+ VALUE n;
+
get_dat1(self);
- return f_xor(f_hash(dat->num), f_hash(dat->den));
+ h[0] = rb_hash(rb_obj_class(self));
+ n = rb_hash(dat->num);
+ h[1] = NUM2LONG(n);
+ n = rb_hash(dat->den);
+ h[2] = NUM2LONG(n);
+ v = rb_memhash(h, sizeof(h));
+ return LONG2FIX(v);
}
static VALUE
@@ -1554,7 +1560,6 @@ Init_Rational(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_integer_p = rb_intern("integer?");