Skip to content

Commit

Permalink
* hash.c (rb_any_hash): treat Qundef like as other special constants.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Feb 21, 2012
1 parent bc3b4dd commit ca9b0f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
4 changes: 3 additions & 1 deletion ChangeLog
@@ -1,4 +1,6 @@
Tue Feb 21 20:22:43 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
Tue Feb 21 20:23:47 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>

* hash.c (rb_any_hash): treat Qundef like as other special constants.

* hash.c (hash_foreach_iter): fix signature.

Expand Down
20 changes: 7 additions & 13 deletions hash.c
Expand Up @@ -80,20 +80,14 @@ rb_any_hash(VALUE a)
VALUE hval;
st_index_t hnum;

switch (TYPE(a)) {
case T_FIXNUM:
case T_SYMBOL:
case T_NIL:
case T_FALSE:
case T_TRUE:
hnum = rb_hash_end(rb_hash_start((unsigned int)a));
break;

case T_STRING:
if (SPECIAL_CONST_P(a)) {
if (a == Qundef) return 0;
hnum = rb_hash_end(rb_hash_start((st_index_t)a));
}
else if (BUILTIN_TYPE(a) == T_STRING) {
hnum = rb_str_hash(a);
break;

default:
}
else {
hval = rb_hash(a);
hnum = FIX2LONG(hval);
}
Expand Down

0 comments on commit ca9b0f5

Please sign in to comment.