# Rational#hash

e\$B\$\$\$D\$@\$C\$?\$+!"e(Brational e\$B\$J\$I\$Ne(B hash
e\$B\$,JQ\$C\$?\$h\$&\$G\$9\$,!“0UL#\$,2r\$C\$F\$\$\$Je(B
e\$B\$\$\$s\$G\$9\$,!”\$\$F\$\$k\$H!"e(B

``````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);
``````

rb_hash e\$B\$rET9ge(B3e\$B2s8F\$s\$G\$\$\$F!“8e\$Ne(B2e\$B2s\$Oe(B NUM2LONG
e\$B\$7\$F\$\$\$F!”:G=i\$N\$O\$=\$&e(B
e\$B\$8\$c\$J\$\$\$s\$G\$9\$,!"\$3\$l\$O\$3\$&\$\$\$&\$b\$N\$H\$\$\$&\$3\$H\$G\$\$\$\$\$s\$G\$9\$+!#e(B

r22317 | mame | 2009-02-15 04:55:34 +0900 (Sun, 15 Feb 2009) | 8 lines

• string.c (rb_hash_uint32, rb_hash_uint, rb_hash_start, rb_hash_end),

• 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]

e\$B\$3\$l\$_\$?\$\$\$G\$9\$,!"H?1~\$,\$J\$\$\$h\$&\$J\$iE,Ev\$KD>\$9\$+!"85\$KLa\$7\$^\$9!#e(B

e\$B\$J\$+\$@\$G\$9!#e(B

At Wed, 22 Jul 2009 20:52:46 +0900,

e\$B\$\$\$D\$@\$C\$?\$+!"e(Brational e\$B\$J\$I\$Ne(B hash e\$B\$,JQ\$C\$?\$h\$&\$G\$9\$,!“0UL#\$,2r\$C\$F\$\$\$Je(B
e\$B\$\$\$s\$G\$9\$,!”\$\$F\$\$k\$H!"e(B

e\$BJQ99\$NM}M3\$Oe(B[ruby-dev:37777]e\$B\$N8eH>\$K\$"\$k\$h\$&\$K!"e(Bhashe\$BCM\$N>WFM\$,B?e(B
e\$B\$\$\$H\$\$\$&LdBj\$N\$?\$a\$G\$9!#e(B

At Fri, 16 Jan 2009 20:00:08 +0900,
Keiju ISHITSUKA wrote in [ruby-dev:37777]:

e\$B\$1\$\$\$8\$e!w\$\$\$7\$D\$+\$G\$9e(B.
(snip)
e\$BF1MM\$G\$9e(B. e\$B\$^\$?e(B, Fixnum#hashe\$B\$He(BObject#hashe\$B\$bJL\$Ne(Bseede\$B\$rM?\$(\$k\$N\$b\$h\$5\$=\$&e(B
e\$B\$J5\$\$,\$7\$^\$9e(B.

``````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);
``````

rb_hash e\$B\$rET9ge(B3e\$B2s8F\$s\$G\$\$\$F!“8e\$Ne(B2e\$B2s\$Oe(B NUM2LONG e\$B\$7\$F\$\$\$F!”:G=i\$N\$O\$=\$&e(B
e\$B\$8\$c\$J\$\$\$s\$G\$9\$,!"\$3\$l\$O\$3\$&\$\$\$&\$b\$N\$H\$\$\$&\$3\$H\$G\$\$\$\$\$s\$G\$9\$+!#e(B

e\$B\$?\$7\$+\$K!"e(BBignume\$B\$,JV\$5\$l\$k\$He(Bhashe\$BCM\$,JQ\$o\$C\$F\$7\$^\$C\$F\$^\$:\$\$\$N\$G:Ge(B
e\$B=i\$be(BNUM2LONG()e\$B\$9\$Y\$-\$G\$7\$g\$&\$,!“e(BArraye\$B\$J\$IB>\$N%/%i%9\$G\$O%5%V%/%ie(B
e\$B%9\$G\$bF1\$8e(Bhashe\$BCM\$K\$J\$k\$h\$&\$K\$J\$C\$F\$\$\$k\$N\$G!”:G=i\$Ne(Brb_hash()
e\$B\$r=|e(B
e\$B\$/\$[\$&\$,\$\$\$\$\$H;W\$\$\$^\$9!#e(B

# Index: complex.c

— complex.c (revision 24266)
+++ complex.c (working copy)
@@ -1157,13 +1157,12 @@ static VALUE
nucomp_hash(VALUE self)
{

• long v, h[3];
• long v, h[2];
VALUE n;

get_dat1(self);

• h[0] = rb_hash(rb_obj_class(self));
n = rb_hash(dat->real);
• h[1] = NUM2LONG(n);
• h[0] = NUM2LONG(n);
n = rb_hash(dat->imag);
• h[2] = NUM2LONG(n);
• h[1] = NUM2LONG(n);
v = rb_memhash(h, sizeof(h));
return LONG2FIX(v);
Index: rational.c
===================================================================
— rational.c (revision 24266)
+++ rational.c (working copy)
@@ -1361,13 +1361,12 @@ static VALUE
nurat_hash(VALUE self)
{
• long v, h[3];
• long v, h[2];
VALUE n;

get_dat1(self);

• h[0] = rb_hash(rb_obj_class(self));
n = rb_hash(dat->num);
• h[1] = NUM2LONG(n);
• h[0] = NUM2LONG(n);
n = rb_hash(dat->den);
• h[2] = NUM2LONG(n);
• h[1] = NUM2LONG(n);
v = rb_memhash(h, sizeof(h));
return LONG2FIX(v);

e\$B\$^\$D\$b\$He(B e\$B\$f\$-\$R\$m\$G\$9e(B

In message “Re: [ruby-dev:38897] Re: Rational#hash”
on Sat, 25 Jul 2009 13:05:12 +0900, Nobuyoshi N.
[email protected] writes:

|> rb_hash e\$B\$rET9ge(B3e\$B2s8F\$s\$G\$\$\$F!“8e\$Ne(B2e\$B2s\$Oe(B NUM2LONG e\$B\$7\$F\$\$\$F!”:G=i\$N\$O\$=\$&e(B
|> e\$B\$8\$c\$J\$\$\$s\$G\$9\$,!"\$3\$l\$O\$3\$&\$\$\$&\$b\$N\$H\$\$\$&\$3\$H\$G\$\$\$\$\$s\$G\$9\$+!#e(B
|
|e\$B\$?\$7\$+\$K!"e(BBignume\$B\$,JV\$5\$l\$k\$He(Bhashe\$BCM\$,JQ\$o\$C\$F\$7\$^\$C\$F\$^\$:\$\$\$N\$G:Ge(B
|e\$B=i\$be(BNUM2LONG()e\$B\$9\$Y\$-\$G\$7\$g\$&\$,!“e(BArraye\$B\$J\$IB>\$N%/%i%9\$G\$O%5%V%/%ie(B
|e\$B%9\$G\$bF1\$8e(Bhashe\$BCM\$K\$J\$k\$h\$&\$K\$J\$C\$F\$\$\$k\$N\$G!”:G=i\$Ne(Brb_hash() e\$B\$r=|e(B
|e\$B\$/\$[\$&\$,\$\$\$\$\$H;W\$\$\$^\$9!#e(B

e\$B%3%_%C%H\$7\$F\$/\$@\$5\$\$!#e(B

e\$BBP1~\$I\$&\$b!#e(B
e\$B\$J\$+\$@\$5\$s\$,%Q%C%A=q\$\$\$?\$N\$KJL?M\$,%3%_%C%H\$7\$F\$?\$H\$O!"\$A\$g\$C\$HIT;W5D!#e(B

e\$B\$J\$+\$@\$G\$9!#e(B

At Sat, 25 Jul 2009 13:05:12 +0900,