From 05e2cba4dc2d2ddd48bbe849acaaa511e181a1a6 Mon Sep 17 00:00:00 2001 From: matz Date: Sat, 2 Sep 2006 14:42:08 +0000 Subject: * ruby.h (struct RArray): embed small arrays. (RARRAY_LEN): defined for accessing array members. (RARRAY_PTR): ditto. * array.c: use RARRAY_LEN and RARRAY_PTR. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@10833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- hash.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'hash.c') diff --git a/hash.c b/hash.c index 6a9ad90ea..866e5cead 100644 --- a/hash.c +++ b/hash.c @@ -1828,8 +1828,8 @@ env_each_key(VALUE ehash) RETURN_ENUMERATOR(ehash, 0, 0); rb_secure(4); keys = env_keys(); - for (i=0; ilen; i++) { - rb_yield(RARRAY(keys)->ptr[i]); + for (i=0; ilen; i++) { - rb_yield(RARRAY(values)->ptr[i]); + for (i=0; ilen; i+=2) { + for (i=0; iptr[i], RARRAY(ary)->ptr[i+1]); + rb_yield_values(2, RARRAY_PTR(ary)[i], RARRAY_PTR(ary)[i+1]); } else { - rb_yield(rb_assoc_new(RARRAY(ary)->ptr[i], RARRAY(ary)->ptr[i+1])); + rb_yield(rb_assoc_new(RARRAY_PTR(ary)[i], RARRAY_PTR(ary)[i+1])); } } return ehash; @@ -1923,12 +1923,12 @@ env_reject_bang(void) rb_secure(4); keys = env_keys(); - for (i=0; ilen; i++) { - VALUE val = rb_f_getenv(Qnil, RARRAY(keys)->ptr[i]); + for (i=0; iptr[i], val))) { - FL_UNSET(RARRAY(keys)->ptr[i], FL_TAINT); - env_delete(Qnil, RARRAY(keys)->ptr[i]); + if (RTEST(rb_yield_values(2, RARRAY_PTR(keys)[i], val))) { + FL_UNSET(RARRAY_PTR(keys)[i], FL_TAINT); + env_delete(Qnil, RARRAY_PTR(keys)[i]); del++; } } @@ -1992,10 +1992,10 @@ env_clear(void) rb_secure(4); keys = env_keys(); - for (i=0; ilen; i++) { - VALUE val = rb_f_getenv(Qnil, RARRAY(keys)->ptr[i]); + for (i=0; iptr[i]); + env_delete(Qnil, RARRAY_PTR(keys)[i]); } } return envtbl; @@ -2239,8 +2239,8 @@ env_replace(VALUE env, VALUE hash) hash = to_hash(hash); rb_hash_foreach(hash, env_replace_i, keys); - for (i=0; ilen; i++) { - env_delete(env, RARRAY(keys)->ptr[i]); + for (i=0; i