diff options
Diffstat (limited to 'src/enum.c')
| -rw-r--r-- | src/enum.c | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/src/enum.c b/src/enum.c index 03508953e..b95956715 100644 --- a/src/enum.c +++ b/src/enum.c @@ -14,25 +14,11 @@ enum_update_hash(mrb_state *mrb, mrb_value self) mrb_int hash; mrb_int index; mrb_int hv; - mrb_value item_hash; - mrb_get_args(mrb, "iio", &hash, &index, &item_hash); - if (mrb_fixnum_p(item_hash)) { - hv = mrb_fixnum(item_hash); - } -#ifndef MRB_WITHOUT_FLOAT - else if (mrb_float_p(item_hash)) { - hv = (mrb_int)mrb_float(item_hash); - } -#endif - else { - mrb_raise(mrb, E_TYPE_ERROR, "can't calculate hash"); - /* not reached */ - hv = 0; - } - hash ^= (hv << (index % 16)); + mrb_get_args(mrb, "iii", &hash, &index, &hv); + hash ^= ((uint32_t)hv << (index % 16)); - return mrb_fixnum_value(hash); + return mrb_int_value(mrb, hash); } void @@ -40,5 +26,5 @@ mrb_init_enumerable(mrb_state *mrb) { struct RClass *enumerable; enumerable = mrb_define_module(mrb, "Enumerable"); /* 15.3.2 */ - mrb_define_module_function(mrb, enumerable, "__update_hash", enum_update_hash, MRB_ARGS_REQ(1)); + mrb_define_module_function(mrb, enumerable, "__update_hash", enum_update_hash, MRB_ARGS_REQ(3)); } |
