diff options
-rw-r--r-- | ChangeLog | 21 | ||||
-rw-r--r-- | array.c | 2 | ||||
-rw-r--r-- | bignum.c | 2 | ||||
-rw-r--r-- | hash.c | 4 | ||||
-rw-r--r-- | internal.h | 3 | ||||
-rw-r--r-- | numeric.c | 2 | ||||
-rw-r--r-- | proc.c | 2 | ||||
-rw-r--r-- | re.c | 4 | ||||
-rw-r--r-- | string.c | 8 |
9 files changed, 33 insertions, 15 deletions
@@ -1,3 +1,24 @@ +Wed Oct 5 01:19:45 2016 NAKAMURA Usaku <[email protected]> + + * internal.h (ST2FIX): new macro to convert st_index_t to Fixnum. + a hash value of Object might be Bignum, but it causes many troubles + expecially the Object is used as a key of a hash. so I've gave up + to do so. + + * array.c (rb_ary_hash): use above macro. + + * bignum.c (rb_big_hash): ditto. + + * hash.c (rb_obj_hash, rb_hash_hash): ditto. + + * numeric.c (rb_dbl_hash): ditto. + + * proc.c (proc_hash): ditto. + + * re.c (rb_reg_hash, match_hash): ditto. + + * string.c (rb_str_hash_m): ditto. + Tue Oct 4 12:59:44 2016 Koichi ITO <[email protected]> * array.c (rb_ary_dig): [DOC] update an example of error message @@ -3927,7 +3927,7 @@ rb_ary_hash(VALUE ary) h = rb_hash_uint(h, NUM2LONG(n)); } h = rb_hash_end(h); - return LONG2FIX(h); + return ST2FIX(h); } /* @@ -6645,7 +6645,7 @@ rb_big_hash(VALUE x) st_index_t hash; hash = rb_memhash(BDIGITS(x), sizeof(BDIGIT)*BIGNUM_LEN(x)) ^ BIGNUM_SIGN(x); - return INT2FIX(hash); + return ST2FIX(hash); } /* @@ -239,7 +239,7 @@ VALUE rb_obj_hash(VALUE obj) { st_index_t hnum = any_hash(obj, objid_hash); - return LONG2FIX(hnum); + return ST2FIX(hnum); } int @@ -2277,7 +2277,7 @@ rb_hash_hash(VALUE hash) rb_hash_foreach(hash, hash_i, (VALUE)&hval); } hval = rb_hash_end(hval); - return INT2FIX(hval); + return ST2FIX(hval); } static int diff --git a/internal.h b/internal.h index 54e5d3bc78..de435ac16b 100644 --- a/internal.h +++ b/internal.h @@ -323,6 +323,9 @@ ntz_intptr(uintptr_t x) { VALUE rb_int128t2big(int128_t n); #endif +#define ST2FIX(h) LONG2FIX((long)(h)) + + /* arguments must be Fixnum */ static inline VALUE rb_fix_mul_fix(VALUE x, VALUE y) @@ -1355,7 +1355,7 @@ rb_dbl_hash(double d) /* normalize -0.0 to 0.0 */ if (d == 0.0) d = 0.0; hash = rb_memhash(&d, sizeof(d)); - return LONG2FIX(hash); + return ST2FIX(hash); } VALUE @@ -1196,7 +1196,7 @@ proc_hash(VALUE self) hash = rb_hash_start(0); hash = rb_hash_proc(hash, self); hash = rb_hash_end(hash); - return LONG2FIX(hash); + return ST2FIX(hash); } /* @@ -2888,7 +2888,7 @@ static VALUE rb_reg_hash(VALUE re) { st_index_t hashval = reg_hash(re); - return LONG2FIX(hashval); + return ST2FIX(hashval); } static st_index_t @@ -2956,7 +2956,7 @@ match_hash(VALUE match) hashval = rb_hash_uint(hashval, rb_memhash(regs->beg, regs->num_regs * sizeof(*regs->beg))); hashval = rb_hash_uint(hashval, rb_memhash(regs->end, regs->num_regs * sizeof(*regs->end))); hashval = rb_hash_end(hashval); - return LONG2FIX(hashval); + return ST2FIX(hashval); } /* @@ -2963,13 +2963,7 @@ static VALUE rb_str_hash_m(VALUE str) { st_index_t hval = rb_str_hash(str); -#if SIZEOF_LONG == SIZEOF_VOIDP - return LONG2FIX((long)hval); -#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP - return LL2NUM((LONG_LONG)hval); -#else -# error unsupported platform -#endif + return ST2FIX(hval); } #define lesser(a,b) (((a)>(b))?(b):(a)) |