From 80467678ddedd41a37724ae6cba1e25f0242823a Mon Sep 17 00:00:00 2001 From: knu Date: Tue, 22 Apr 2008 10:36:31 +0000 Subject: * enumerator.c (enumerator_initialize): Remove an undocumented feature (passing a block to the constructor) that's broken. This is not what I intended. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ enumerator.c | 27 +-------------------------- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index fd721095f8..a731c64a5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Apr 22 19:23:05 2008 Akinori MUSHA + + * enumerator.c (enumerator_initialize): Remove an undocumented + feature (passing a block to the constructor) that's broken. + This is not what I intended. + Tue Apr 22 17:54:05 2008 URABE Shyouhei * vm_core.h (exec_event_hooks): ``inline'' is a type modifier, not diff --git a/enumerator.c b/enumerator.c index c52f61d9aa..ced64bd4eb 100644 --- a/enumerator.c +++ b/enumerator.c @@ -26,19 +26,9 @@ static VALUE sym_each; VALUE rb_eStopIteration; -static VALUE -proc_call(VALUE proc, VALUE args) -{ - if (TYPE(args) != T_ARRAY) { - args = rb_ary_new3(1, args); - } - return rb_proc_call(proc, args); -} - struct enumerator { VALUE obj; ID meth; - VALUE proc; VALUE args; rb_block_call_func *iter; VALUE fib; @@ -51,7 +41,6 @@ enumerator_mark(void *p) { struct enumerator *ptr = p; rb_gc_mark(ptr->obj); - rb_gc_mark(ptr->proc); rb_gc_mark(ptr->args); rb_gc_mark(ptr->fib); rb_gc_mark(ptr->dst); @@ -74,13 +63,6 @@ enumerator_ptr(VALUE obj) return ptr; } -static VALUE -enumerator_iter_i(VALUE i, VALUE enum_obj, int argc, VALUE *argv) -{ - struct enumerator *e = (struct enumerator *)enum_obj; - return rb_yield(proc_call(e->proc, i)); -} - /* * call-seq: * obj.to_enum(method = :each, *args) @@ -237,13 +219,7 @@ enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, VALUE *argv) ptr->obj = obj; ptr->meth = rb_to_id(meth); - if (rb_block_given_p()) { - ptr->proc = rb_block_proc(); - ptr->iter = enumerator_iter_i; - } - else { - ptr->iter = enumerator_each_i; - } + ptr->iter = enumerator_each_i; if (argc) ptr->args = rb_ary_new4(argc, argv); ptr->fib = 0; ptr->dst = Qnil; @@ -297,7 +273,6 @@ enumerator_init_copy(VALUE obj, VALUE orig) ptr1->obj = ptr0->obj; ptr1->meth = ptr0->meth; - ptr1->proc = ptr0->proc; ptr1->iter = ptr0->iter; ptr1->args = ptr0->args; ptr1->fib = 0; -- cgit v1.2.3