summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-08 06:55:24 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-08 06:55:24 +0000
commitab6efa5be2f5a2fb1b5a05a90f398b27ea52617a (patch)
tree621c25b0d22646d05c80e79886314a79061b86b4 /hash.c
parent06f624b8915fbddbb13c010ee1a61f266708285b (diff)
downloadbundler-ab6efa5be2f5a2fb1b5a05a90f398b27ea52617a.tar.gz
object.c: hash value from objid with salt
* hash.c (rb_objid_hash): return hash value from object ID with a salt, extract from rb_any_hash(). * object.c (rb_obj_hash): return same value as rb_any_hash(). fix r44125. [ruby-core:59638] [Bug #9381] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/hash.c b/hash.c
index 0eca4b99a4..51ba38dd58 100644
--- a/hash.c
+++ b/hash.c
@@ -122,6 +122,8 @@ rb_hash(VALUE obj)
return hval;
}
+st_index_t rb_objid_hash(st_index_t index);
+
static st_index_t
rb_any_hash(VALUE a)
{
@@ -130,9 +132,7 @@ rb_any_hash(VALUE a)
if (SPECIAL_CONST_P(a)) {
if (a == Qundef) return 0;
- hnum = rb_hash_start((st_index_t)a);
- hnum = rb_hash_uint(hnum, (st_index_t)rb_any_hash);
- hnum = rb_hash_end(hnum);
+ hnum = rb_objid_hash((st_index_t)a);
}
else if (BUILTIN_TYPE(a) == T_STRING) {
hnum = rb_str_hash(a);
@@ -145,6 +145,15 @@ rb_any_hash(VALUE a)
return (st_index_t)RSHIFT(hnum, 1);
}
+st_index_t
+rb_objid_hash(st_index_t index)
+{
+ st_index_t hnum = rb_hash_start(index);
+ hnum = rb_hash_uint(hnum, (st_index_t)rb_any_hash);
+ hnum = rb_hash_end(hnum);
+ return hnum;
+}
+
static const struct st_hash_type objhash = {
rb_any_cmp,
rb_any_hash,