summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authortarui <tarui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-15 17:08:52 +0000
committertarui <tarui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-15 17:08:52 +0000
commit9e96b1edea5c52fba05a30fc602288bb100acea7 (patch)
tree21e5632515f0ffd3406d21cb94f80b3a2b949751 /hash.c
parent7664609f928b44e3bfea944f644114903067468a (diff)
revert r43675 and r43683 without tests for applying rollback patch.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/hash.c b/hash.c
index d1816ff..a37318b 100644
--- a/hash.c
+++ b/hash.c
@@ -173,7 +173,6 @@ struct hash_foreach_arg {
VALUE hash;
rb_foreach_func *func;
VALUE arg;
- VALUE marker;
};
static int
@@ -189,10 +188,6 @@ hash_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
if (RHASH(arg->hash)->ntbl != tbl) {
rb_raise(rb_eRuntimeError, "rehash occurred during iteration");
}
- if (DATA_PTR(arg->marker)) {
- RHASH_ITER_LEV(arg->hash)++;
- DATA_PTR(arg->marker) = 0;
- }
switch (status) {
case ST_DELETE:
FL_SET(arg->hash, HASH_DELETED);
@@ -206,14 +201,8 @@ hash_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
}
static VALUE
-hash_foreach_ensure(VALUE arg)
+hash_foreach_ensure(VALUE hash)
{
- struct hash_foreach_arg *argp = (struct hash_foreach_arg *)arg;
- VALUE hash = argp->hash;
-
- if (DATA_PTR(argp->marker)) return 0;
- DATA_PTR(argp->marker) = (void *)-1;
-
if (--RHASH_ITER_LEV(hash) == 0) {
if (FL_TEST(hash, HASH_DELETED)) {
st_cleanup_safe(RHASH(hash)->ntbl, (st_data_t)Qundef);
@@ -240,12 +229,11 @@ rb_hash_foreach(VALUE hash, int (*func)(ANYARGS), VALUE farg)
if (!RHASH(hash)->ntbl)
return;
+ RHASH_ITER_LEV(hash)++;
arg.hash = hash;
arg.func = (rb_foreach_func *)func;
arg.arg = farg;
- arg.marker = Data_Wrap_Struct(0, 0, 0, 0);
- RHASH_ITER_LEV(hash)++;
- rb_ensure(hash_foreach_call, (VALUE)&arg, hash_foreach_ensure, (VALUE)&arg);
+ rb_ensure(hash_foreach_call, (VALUE)&arg, hash_foreach_ensure, hash);
}
static VALUE