From 6a2cf46ff923a0969ba734f931fbdfbae6251929 Mon Sep 17 00:00:00 2001 From: Yukihiro Matsumoto Date: Fri, 1 Jun 2012 01:25:16 +0900 Subject: hash function should use #hash internally --- src/hash.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/hash.c b/src/hash.c index 371ac777a..8cb039cea 100644 --- a/src/hash.c +++ b/src/hash.c @@ -21,11 +21,12 @@ static inline khint_t mrb_hash_ht_hash_func(mrb_state *mrb, mrb_value key) { - char type = mrb_type(key); - mrb_value s1 = mrb_str_new(mrb, &type, 1); - mrb_value s2 = mrb_inspect(mrb, key); - s1 = mrb_str_cat(mrb, s1, RSTRING_PTR(s2), RSTRING_LEN(s2)); - return kh_str_hash_func(mrb, RSTRING_PTR(s1)); + khint_t h = mrb_type(key) << 24; + mrb_value h2; + + h2 = mrb_funcall(mrb, key, "hash", 0, 0); + h ^= h2.value.i; + return h; } static inline khint_t -- cgit v1.2.3