ruby-changes:29134
From: akr <ko1@a...>
Date: Sun, 9 Jun 2013 01:00:27 +0900 (JST)
Subject: [ruby-changes:29134] akr:r41186 (trunk): * hash.c (rb_hash): Use rb_integer_pack to obtain least significant
akr 2013-06-09 01:00:16 +0900 (Sun, 09 Jun 2013) New Revision: 41186 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41186 Log: * hash.c (rb_hash): Use rb_integer_pack to obtain least significant long integer. Modified files: trunk/ChangeLog trunk/hash.c Index: ChangeLog =================================================================== --- ChangeLog (revision 41185) +++ ChangeLog (revision 41186) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Jun 9 00:59:04 2013 Tanaka Akira <akr@f...> + + * hash.c (rb_hash): Use rb_integer_pack to obtain least significant + long integer. + Sat Jun 8 23:56:00 2013 Tanaka Akira <akr@f...> * numeric.c (rb_num_to_uint): Use rb_absint_size instead of Index: hash.c =================================================================== --- hash.c (revision 41185) +++ hash.c (revision 41186) @@ -89,7 +89,16 @@ rb_hash(VALUE obj) https://github.com/ruby/ruby/blob/trunk/hash.c#L89 return hval; case T_BIGNUM: - return LONG2FIX(((long*)(RBIGNUM_DIGITS(hval)))[0]); + { + int sign; + unsigned long ul; + rb_integer_pack(hval, &sign, NULL, &ul, 1, sizeof(ul), 0, + INTEGER_PACK_LSWORD_FIRST|INTEGER_PACK_NATIVE_BYTE_ORDER); + ul &= (1UL << (sizeof(long)*CHAR_BIT-1)) - 1; + if (sign < 0) + return LONG2FIX(-(long)ul); + return LONG2FIX((long)ul); + } default: hval = rb_to_int(hval); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/