diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-19 17:29:09 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-19 17:29:09 +0000 |
| commit | dcfc52b9dcc4e81eb3c9d34fbf88fe4510b03885 (patch) | |
| tree | bfeda74860fbad889193523c115b41d54ba45d63 /hash.c | |
| parent | 881d8ed78ad32af691f4a2ac292c575ec60cb301 (diff) | |
| download | ruby-dcfc52b9dcc4e81eb3c9d34fbf88fe4510b03885.tar.gz ruby-dcfc52b9dcc4e81eb3c9d34fbf88fe4510b03885.tar.xz ruby-dcfc52b9dcc4e81eb3c9d34fbf88fe4510b03885.zip | |
* misc/ruby-mode.el (ruby-calculate-indent): proper indentation
inside of parentheses. [ruby-dev:22308]
* hash.c (delete_if_i): do not use ST_DELETE for thread safety.
[ruby-dev:21899] (not fully solved)
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@5223 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
| -rw-r--r-- | hash.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -460,12 +460,12 @@ rb_hash_shift(hash) } static enum st_retval -delete_if_i(key, value) - VALUE key, value; +delete_if_i(key, value, keys) + VALUE key, value, keys; { - if (key == Qundef) return ST_CONTINUE; - if (RTEST(rb_yield_values(2, key, value))) - return ST_DELETE; + if (key != Qundef && RTEST(rb_yield_values(2, key, value))) { + rb_ary_push(keys, key); + } return ST_CONTINUE; } @@ -473,8 +473,14 @@ VALUE rb_hash_delete_if(hash) VALUE hash; { + VALUE keys = rb_ary_new(); + long i; + rb_hash_modify(hash); - rb_hash_foreach(hash, delete_if_i, 0); + rb_hash_foreach(hash, delete_if_i, keys); + for (i=0; i<RARRAY(keys)->len; i++) { + st_delete(RHASH(hash)->tbl, &RARRAY(keys)->ptr[i], 0); + } return hash; } |
