summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authorglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-30 11:58:33 (GMT)
committerglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-30 11:58:33 (GMT)
commitc879b60152ccfb4317ae86c22f8947c3b1d442bb (patch)
treeac6400685ce96c638269658972e5a1ec9d6c4cbc /hash.c
parente7c8073a62784ed88e64ba7b2e321b5e1aa10e26 (diff)
hash.c: remove special treatments on deletion
st.c was improved in r56650 that it permits deletion during iteration. In this commit, special treatments for previous implementation are removed. * hash.c: don't use *_check and *_safe functions in st.c * internal.h: remove HASH_DELETED flag git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/hash.c b/hash.c
index 7198e8a..b666fd1 100644
--- a/hash.c
+++ b/hash.c
@@ -348,7 +348,6 @@ hash_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
}
switch (status) {
case ST_DELETE:
- FL_SET(arg->hash, HASH_DELETED);
return ST_DELETE;
case ST_CONTINUE:
break;
@@ -368,12 +367,7 @@ hash_foreach_ensure_rollback(VALUE hash)
static VALUE
hash_foreach_ensure(VALUE hash)
{
- if (--RHASH_ITER_LEV(hash) == 0) {
- if (FL_TEST(hash, HASH_DELETED)) {
- st_cleanup_safe(RHASH(hash)->ntbl, (st_data_t)Qundef);
- FL_UNSET(hash, HASH_DELETED);
- }
- }
+ RHASH_ITER_LEV(hash)--;
return 0;
}
@@ -1108,11 +1102,6 @@ rb_hash_delete_entry(VALUE hash, VALUE key)
if (!RHASH(hash)->ntbl) {
return Qundef;
}
- else if (RHASH_ITER_LEV(hash) > 0 &&
- (st_delete_safe(RHASH(hash)->ntbl, &ktmp, &val, (st_data_t)Qundef))) {
- FL_SET(hash, HASH_DELETED);
- return (VALUE)val;
- }
else if (st_delete(RHASH(hash)->ntbl, &ktmp, &val)) {
return (VALUE)val;
}
@@ -2120,7 +2109,7 @@ rb_hash_keys(VALUE hash)
rb_gc_writebarrier_remember(keys);
RARRAY_PTR_USE(keys, ptr, {
- size = st_keys_check(table, ptr, size, Qundef);
+ size = st_keys(table, ptr, size);
});
rb_ary_set_len(keys, size);
}
@@ -2164,7 +2153,7 @@ rb_hash_values(VALUE hash)
rb_gc_writebarrier_remember(values);
RARRAY_PTR_USE(values, ptr, {
- size = st_values_check(table, ptr, size, Qundef);
+ size = st_values(table, ptr, size);
});
rb_ary_set_len(values, size);
}