# Hash value of { n =\> n }

**URL:** <https://www.ruby-forum.com/t/hash-value-of-n-n/115097>\
**Category:** Development\
**Created:** [September 20, 2007, 3:59pm UTC](https://www.ruby-forum.com/t/hash-value-of-n-n/115097 "2007-09-20T15:59:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yusuke\_ENDOH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/c89c15/32.png) [@Yusuke\_ENDOH](https://www.ruby-forum.com/u/Yusuke_ENDOH)\
**Post date:** [September 20, 2007, 3:59pm UTC](https://www.ruby-forum.com/t/hash-value-of-n-n/115097/1 "2007-09-20T15:59:30Z")

</div>

e$B1sF#$H?=$7$^$9e(B

1.9 e$B$G0J2\<$N%3!\<%I$r\<B9T$9$k$H!"$+$J$j;~4V$,$+$+$j$^$9!#e(B

$ time ./ruby -ve ‘h = {}; 10000.times {|x| h[{ x =\> x }] = 1 }’  
ruby 1.9.0 (2007-09-15 patchlevel 0) [i686-linux]

real 0m12.369s  
user 0m9.050s  
sys 0m3.280s

e$BG$0U$Ne(B x e$B$K$D$$$Fe(B { x =\> x } e$B$N%O%C%7%eCM$,$9$Y$Fe(B 1  
e$B$G$"$k$?$a!“e(B  
e$B\>WFM$7$^$/$C$F$$$k$h$&$G$9!#e(B  
e$BBQ\>WFM@-$O$=$l$[$I=EMW$8$c$J$$$+$b$7$l$^$;$s$,!”$A$g$C$H4JC1$Ke(B  
e$B\>WFM$7$9$.$J5$$b$7$^$9!#$I$&$G$7$g$&$+!#e(B

e$B\>e$N%3!\<%I$K$D$$$F$O0J2\<$N%Q%C%A$G$H$j$"$($:2r7h$7$^$9!#e(B

# Index: hash.c

— hash.c (revision 13472)  
+++ hash.c (working copy)  
@@ -1461,6 +1461,7 @@  
{  
if (key == Qundef) return ST\_CONTINUE;  
\*hval ^= rb\_hash(key);

- \*hval \*= 137;  
\*hval ^= rb\_hash(val);  
return ST\_CONTINUE;  
}

$ time ./ruby -ve ‘h = {}; 10000.times {|x| h[{ x =\> x }] = 1 }’  
ruby 1.9.0 (2007-09-15 patchlevel 0) [i686-linux]

real 0m0.182s  
user 0m0.030s  
sys 0m0.150s
