зеркало из https://github.com/github/ruby.git
* hash.c (rb_hash_delete_if, rb_hash_reject_bang, env_delete_if,
env_reject_bang): Return an enumerator if no block is given. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
6866bce757
Коммит
ac5b69acb8
|
@ -1,3 +1,8 @@
|
|||
Mon Apr 14 17:23:27 2008 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* hash.c (rb_hash_delete_if, rb_hash_reject_bang, env_delete_if,
|
||||
env_reject_bang): Return an enumerator if no block is given.
|
||||
|
||||
Mon Apr 14 14:33:59 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* compile.c, compile.h (compile_debug): made runtime option.
|
||||
|
|
10
hash.c
10
hash.c
|
@ -787,6 +787,7 @@ delete_if_i(VALUE key, VALUE value, VALUE hash)
|
|||
VALUE
|
||||
rb_hash_delete_if(VALUE hash)
|
||||
{
|
||||
RETURN_ENUMERATOR(hash, 0, 0);
|
||||
rb_hash_modify(hash);
|
||||
rb_hash_foreach(hash, delete_if_i, hash);
|
||||
return hash;
|
||||
|
@ -804,6 +805,8 @@ VALUE
|
|||
rb_hash_reject_bang(VALUE hash)
|
||||
{
|
||||
int n;
|
||||
|
||||
RETURN_ENUMERATOR(hash, 0, 0);
|
||||
if (!RHASH(hash)->ntbl)
|
||||
return Qnil;
|
||||
n = RHASH(hash)->ntbl->num_entries;
|
||||
|
@ -2142,12 +2145,13 @@ env_each_pair(VALUE ehash)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
env_reject_bang(void)
|
||||
env_reject_bang(VALUE ehash)
|
||||
{
|
||||
volatile VALUE keys;
|
||||
long i;
|
||||
int del = 0;
|
||||
|
||||
RETURN_ENUMERATOR(ehash, 0, 0);
|
||||
rb_secure(4);
|
||||
keys = env_keys();
|
||||
for (i=0; i<RARRAY_LEN(keys); i++) {
|
||||
|
@ -2165,9 +2169,9 @@ env_reject_bang(void)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
env_delete_if(void)
|
||||
env_delete_if(VALUE ehash)
|
||||
{
|
||||
env_reject_bang();
|
||||
env_reject_bang(ehash);
|
||||
return envtbl;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче