зеркало из https://github.com/github/ruby.git
* hash.c (rb_hash): Use rb_integer_pack to obtain least significant
long integer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
893a8bb653
Коммит
e3bc7eec5f
|
@ -1,3 +1,8 @@
|
|||
Sun Jun 9 00:59:04 2013 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* hash.c (rb_hash): Use rb_integer_pack to obtain least significant
|
||||
long integer.
|
||||
|
||||
Sat Jun 8 23:56:00 2013 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* numeric.c (rb_num_to_uint): Use rb_absint_size instead of
|
||||
|
|
11
hash.c
11
hash.c
|
@ -89,7 +89,16 @@ rb_hash(VALUE obj)
|
|||
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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче