aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-21 22:52:38 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-21 22:52:38 +0000
commit51281b961be085be5a29088ada5118699035306b (patch)
treed5adc6176aa167e868d3c6081e794238b98251ac
parent5b950717b7bbcf8fa3b9362060c02badd87d2b5a (diff)
downloadruby-51281b961be085be5a29088ada5118699035306b.tar.gz
* bignum.c (rb_big_hash): use rb_memhash().
* numeric.c (flo_hash): simplified. klass need not to affect resulting hash value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--bignum.c10
-rw-r--r--numeric.c4
3 files changed, 11 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index f0ae8cef7c..23defd152a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Sep 22 06:53:22 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_big_hash): use rb_memhash().
+
+ * numeric.c (flo_hash): simplified. klass need not to affect
+ resulting hash value.
+
Fri Sep 22 02:06:26 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* .cvsignore: ignore timestamp files and installed list file.
diff --git a/bignum.c b/bignum.c
index e3e8d80d9a..ecf2872f08 100644
--- a/bignum.c
+++ b/bignum.c
@@ -1887,14 +1887,10 @@ rb_big_aref(VALUE x, VALUE y)
static VALUE
rb_big_hash(VALUE x)
{
- long i, len, key;
- BDIGIT *digits;
+ int hash;
- key = 0; digits = BDIGITS(x); len = RBIGNUM(x)->len;
- for (i=0; i<len; i++) {
- key ^= *digits++;
- }
- return LONG2FIX(key);
+ hash = rb_memhash(BDIGITS(x), BITSPERDIG*RBIGNUM(x)->len) ^ RBIGNUM(x)->sign;
+ return INT2FIX(hash);
}
/*
diff --git a/numeric.c b/numeric.c
index 5a7e1dcff2..e812389c38 100644
--- a/numeric.c
+++ b/numeric.c
@@ -839,9 +839,7 @@ flo_hash(VALUE num)
int hash;
d = RFLOAT(num)->value;
- if (d == 0) d = fabs(d);
- hash = rb_memhash(&d, sizeof(d)) ^ RBASIC(num)->klass;
- if (hash < 0) hash = -hash;
+ hash = rb_memhash(&d, sizeof(d));
return INT2FIX(hash);
}