summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKOBAYASHI Shuji <[email protected]>2020-07-25 16:59:02 +0900
committerHiroshi Mimaki <[email protected]>2020-07-29 09:17:32 +0900
commit112120969d5a08c9d496e176a2655bbe1ff7f97b (patch)
tree2698c02b2d09e7128bd5e4d3c6fd2485f2706891
parent63956036e116ef6a33a91e16348c4d1a09f6f72c (diff)
downloadmruby-112120969d5a08c9d496e176a2655bbe1ff7f97b.tar.gz
mruby-112120969d5a08c9d496e176a2655bbe1ff7f97b.zip
Use type tag for hash code in `ht_hash_func()`2.1.2-rc2
The function corresponding to `ht_hash_func()` was as follows in the days of khash implementation (before d78acc7a). ```c mrb_hash_ht_hash_func(mrb_state *mrb, mrb_value key) { enum mrb_vtype t = mrb_type(key); ... switch (t) { ... default: hv = mrb_funcall(mrb, key, "hash", 0); h = (khint_t)t ^ (khint_t)mrb_fixnum(hv); break; } ... } ``` When switched to the segmented list implementation (d78acc7a), this function was changed as follows. ```c sg_hash_func(mrb_state *mrb, seglist *t, mrb_value key) { enum mrb_vtype tt = mrb_type(key); ... switch (tt) { ... default: hv = mrb_funcall(mrb, key, "hash", 0); h = (size_t)t ^ (size_t)mrb_fixnum(hv); break; } ... } ``` Since the argument `t` was added, the variable for type tag was changed from `t` to `tt`, but the variable used in the expression of `h` remained `t`. Probably this is an omission of change, so fixed it.
-rw-r--r--src/hash.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/hash.c b/src/hash.c
index 4d5310903..d9ee483d5 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -73,7 +73,7 @@ ht_hash_func(mrb_state *mrb, htable *t, mrb_value key)
default:
hv = mrb_funcall(mrb, key, "hash", 0);
- h = (size_t)t ^ (size_t)mrb_fixnum(hv);
+ h = (size_t)tt ^ (size_t)mrb_fixnum(hv);
break;
}
if (index && (index != t->index || capa != index->capa)) {