From 71b059e0703db9406a04d2f7c04a4823a1013ccf Mon Sep 17 00:00:00 2001 From: knu Date: Mon, 26 May 2008 08:49:08 +0000 Subject: * enumerator.c (struct enumerator, enumerator_init) (enumerator_init_copy, enumerator_each): Eliminate iter. (enumerator_ptr): Do not hardcode the class name. (enumerator_with_index): Delay variable initialization after RETURN_ENUMERATOR(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ enumerator.c | 13 ++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 704ce57498..a9574a6598 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Mon May 26 17:48:42 2008 Akinori MUSHA + + * enumerator.c (struct enumerator, enumerator_init) + (enumerator_init_copy, enumerator_each): Eliminate iter. + (enumerator_ptr): Do not hardcode the class name. + (enumerator_with_index): Delay variable initialization after + RETURN_ENUMERATOR(). + Mon May 26 17:23:49 2008 NAKAMURA Usaku * file.c (file_expand_path): add more space for '/'. diff --git a/enumerator.c b/enumerator.c index 6602e2c176..a930c2bfa6 100644 --- a/enumerator.c +++ b/enumerator.c @@ -30,7 +30,6 @@ struct enumerator { VALUE obj; ID meth; VALUE args; - rb_block_call_func *iter; VALUE fib; VALUE dst; VALUE no_next; @@ -54,8 +53,8 @@ enumerator_ptr(VALUE obj) Data_Get_Struct(obj, struct enumerator, ptr); if (RDATA(obj)->dmark != enumerator_mark) { rb_raise(rb_eTypeError, - "wrong argument type %s (expected Enumerable::Enumerator)", - rb_obj_classname(obj)); + "wrong argument type %s (expected %s)", + rb_obj_classname(obj), rb_class2name(rb_cEnumerator)); } if (!ptr) { rb_raise(rb_eArgError, "uninitialized enumerator"); @@ -222,7 +221,6 @@ enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, VALUE *argv) ptr->obj = obj; ptr->meth = rb_to_id(meth); - ptr->iter = enumerator_each_i; if (argc) ptr->args = rb_ary_new4(argc, argv); ptr->fib = 0; ptr->dst = Qnil; @@ -272,7 +270,6 @@ enumerator_init_copy(VALUE obj, VALUE orig) ptr1->obj = ptr0->obj; ptr1->meth = ptr0->meth; - ptr1->iter = ptr0->iter; ptr1->args = ptr0->args; ptr1->fib = 0; @@ -306,7 +303,8 @@ enumerator_each(VALUE obj) argc = RARRAY_LEN(e->args); argv = RARRAY_PTR(e->args); } - return rb_block_call(e->obj, e->meth, argc, argv, e->iter, (VALUE)e); + return rb_block_call(e->obj, e->meth, argc, argv, + enumerator_each_i, (VALUE)e); } static VALUE @@ -329,12 +327,13 @@ enumerator_with_index_i(VALUE val, VALUE *memo) static VALUE enumerator_with_index(VALUE obj) { - struct enumerator *e = enumerator_ptr(obj); + struct enumerator *e; VALUE memo = 0; int argc = 0; VALUE *argv = 0; RETURN_ENUMERATOR(obj, 0, 0); + e = enumerator_ptr(obj); if (e->args) { argc = RARRAY_LEN(e->args); argv = RARRAY_PTR(e->args); -- cgit v1.2.3