diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-04-08 13:28:13 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-08 13:28:13 +0900 |
commit | 9e6e39c3512f7a962c44dc3729c98a0f8be90341 (patch) | |
tree | 901a22676d54d78240e450b64a8cd06eb1703910 /hash.c | |
parent | 5ac4bf2cd87e1eb5779ca5ae7f96a1a22e8436d9 (diff) |
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
Notes
Notes:
Merged-By: shyouhei <shyouhei@ruby-lang.org>
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -11,7 +11,7 @@ **********************************************************************/ -#include "ruby/config.h" +#include "ruby/3/config.h" #include <errno.h> @@ -150,10 +150,12 @@ rb_hash(VALUE obj) unsigned long ul; sign = rb_integer_pack(hval, &ul, 1, sizeof(ul), 0, INTEGER_PACK_NATIVE_BYTE_ORDER); - ul &= (1UL << (sizeof(long)*CHAR_BIT-1)) - 1; - if (sign < 0) - return LONG2FIX(-(long)ul); - return LONG2FIX((long)ul); + if (sign < 0) { + hval = LONG2FIX(ul | FIXNUM_MIN); + } + else { + hval = LONG2FIX(ul & FIXNUM_MAX); + } } hval = rb_to_int(hval); } |