ruby-changes:47961
From: glass <ko1@a...>
Date: Sat, 30 Sep 2017 20:58:39 +0900 (JST)
Subject: [ruby-changes:47961] glass:r60076 (trunk): hash.c: remove special treatments on deletion
glass 2017-09-30 20:58:33 +0900 (Sat, 30 Sep 2017) New Revision: 60076 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60076 Log: 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 Modified files: trunk/hash.c trunk/internal.h Index: hash.c =================================================================== --- hash.c (revision 60075) +++ hash.c (revision 60076) @@ -348,7 +348,6 @@ hash_foreach_iter(st_data_t key, st_data https://github.com/ruby/ruby/blob/trunk/hash.c#L348 } 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) https://github.com/ruby/ruby/blob/trunk/hash.c#L367 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 k https://github.com/ruby/ruby/blob/trunk/hash.c#L1102 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) https://github.com/ruby/ruby/blob/trunk/hash.c#L2109 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) https://github.com/ruby/ruby/blob/trunk/hash.c#L2153 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); } Index: internal.h =================================================================== --- internal.h (revision 60075) +++ internal.h (revision 60076) @@ -1259,7 +1259,6 @@ VALUE rb_hash_keys(VALUE hash); https://github.com/ruby/ruby/blob/trunk/internal.h#L1259 VALUE rb_hash_values(VALUE hash); VALUE rb_hash_rehash(VALUE hash); int rb_hash_add_new_element(VALUE hash, VALUE key, VALUE val); -#define HASH_DELETED FL_USER1 #define HASH_PROC_DEFAULT FL_USER2 /* inits.c */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/