e$B1sF#$G$9!#e(B
e$B8=:_$Ne(B Enumerator#each e$B$O!"e(B1 e$B2s$N%V%m%C%/8F$S=P$7$Ge(B 2
e$B2sJ,$Ne(B yield e$B$r<B9Te(B
e$B$7$F$$$^$9!#e(B
- Enumerator#each e$B$,85$N%a%=%C%I$re(B rb_block_call e$B$G8F$Ve(B
(e$B$3$N$H$-%V%m%C%/$H$7$Fe(B enumerator_each_i e$B$rM?$($ke(B) - e$B85$N%a%=%C%I$,e(B yield e$B$7$F8=:_$N%V%m%C%/e(B
(enumerator_each_i) e$B$r8F$Ve(B - enumerator_each_i e$B$,e(B yield e$B$7$F<B:]$N%V%m%C%/$r8F$Ve(B
e$B$=$3$Ge(B rb_block_call
e$B$K8=:$N%V%m%C%/$rEO$;$k$h$&$K$7$F$$^$7$?!#e(B
e$B$3$&$9$k$H!"e(Byield e$B$Oe(B 1 e$B2s$G:Q$_$^$9!#e(B
- Enumerator#each e$B$,85$N%a%=%C%I$re(B rb_block_call e$B$G8F$Ve(B
(e$B$3$N$H$-%V%m%C%/$H$7$F8=:_$N%V%m%C%/$r$=$N$^$^EO$9e(B) - e$B85$N%a%=%C%I$,e(B yield e$B$7$F<B:]$N%V%m%C%/$r8F$Ve(B
e$B0J2<$N%Y%s%A%^!<%/$G;n$9$H!"%Q%C%AA0$Ge(B 1.49 e$BIC!"%Q%C%A8e$Ge(B
1.00 e$BIC$He(B
e$B$J$j$^$7$?!#e(B
GC.disable
a = [0] * 5000000
t = Time.now
a.to_enum.each {|x| }
p Time.now - t
e$B$A$J$_$Ke(B a.to_enum.each e$B$NBe$o$j$Ke(B a.each
e$B$HD>@\8F$s$@>l9g$G$be(B 1.00 e$BICe(B
e$B$G$9!#%a%=%C%I$r%Y!<%9$H$7$?e(B Enumerator e$B$,e(B to_enum
e$B$7$J$$>l9g$HB=?’$J$$e(B
e$BB.EY$K$J$C$?$H;W$$$^$9!#e(B
e$B$3$NOC$Oe(B Enumerator e$B$KFC2=$7$?OC$G$O$J$/!"e(BARGF.each_line
e$B$de(B each_byte
e$B$J$I$bF1$8$h$&$Ke(B 2 e$BCJ3,e(B yield
e$B$K$J$C$F$$$?$N$G!"8=:_$N%V%m%C%/$rD>@\e(B
e$BEO$9$h$&$K$7$?$H$3$m!"0J2<$,e(B 0.20 e$BIC$+$ie(B 0.18
e$BIC$K9bB.2=$7$^$7$?!#e(B
ruby -e ‘$<.each_line {|l| }’ *.c
e$B6qBNE*$J%Q%C%A$NFbMF$O!"e(Brb_block_call e$B$Ne(B bl_proc e$B$Ke(B
NULL e$B$,EO$5$l$?$ie(B
e$B8=:$N%V%m%C%/$r;H$&$h$&$K$9$k$H$$$&$b$N$G$9!#e(B
e$B%3%%C%H$7$F$b$$$$$G$7$g$&$+!#e(B
diff --git a/enumerator.c b/enumerator.c
index 7c50f3d…34d16c0 100644
— a/enumerator.c
+++ b/enumerator.c
@@ -330,12 +330,6 @@ enumerator_allocate(VALUE klass)
}
static VALUE
-enumerator_each_i(VALUE v, VALUE enum_obj, int argc, VALUE *argv)
-{
- return rb_yield_values2(argc, argv);
-}
-static VALUE
enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, VALUE
*argv)
{
struct enumerator *ptr;
@@ -473,7 +467,7 @@ static VALUE
enumerator_each(VALUE obj)
{
if (!rb_block_given_p()) return obj;
- return enumerator_block_call(obj, enumerator_each_i, obj);
- return enumerator_block_call(obj, 0, obj);
}
static VALUE
diff --git a/io.c b/io.c
index 643455e…3b8bd25 100644
— a/io.c
+++ b/io.c
@@ -9148,7 +9148,7 @@ argf_each_line(int argc, VALUE *argv, VALUE argf)
RETURN_ENUMERATOR(argf, argc, argv);
for (; {
if (!next_argv()) return argf;
- rb_block_call(ARGF.current_file, rb_intern(“each_line”), argc, argv,
rb_yield, 0);
- rb_block_call(ARGF.current_file, rb_intern(“each_line”), argc, argv,
0, 0);
ARGF.next_p = 1;
}
}
@@ -9182,7 +9182,7 @@ argf_each_byte(VALUE argf)
RETURN_ENUMERATOR(argf, 0, 0);
for (; {
if (!next_argv()) return argf;
- rb_block_call(ARGF.current_file, rb_intern(“each_byte”), 0, 0,
rb_yield, 0);
- rb_block_call(ARGF.current_file, rb_intern(“each_byte”), 0, 0, 0, 0);
ARGF.next_p = 1;
}
}
@@ -9212,7 +9212,7 @@ argf_each_char(VALUE argf)
RETURN_ENUMERATOR(argf, 0, 0);
for (; {
if (!next_argv()) return argf;
- rb_block_call(ARGF.current_file, rb_intern(“each_char”), 0, 0,
rb_yield, 0);
- rb_block_call(ARGF.current_file, rb_intern(“each_char”), 0, 0, 0, 0);
ARGF.next_p = 1;
}
}
diff --git a/vm_eval.c b/vm_eval.c
index f0b2316…9276f0a 100644
— a/vm_eval.c
+++ b/vm_eval.c
@@ -828,9 +828,15 @@ rb_iterate(VALUE (* it_proc) (VALUE), VALUE data1,
if (state == 0) {
iter_retry:
{
-
rb_block_t *blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(th->cfp);
-
blockptr->iseq = (void *)node;
-
blockptr->proc = 0;
-
rb_block_t *blockptr;
-
if (bl_proc) {
- blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(th->cfp);
- blockptr->iseq = (void *)node;
- blockptr->proc = 0;
-
}
-
else {
- blockptr = GC_GUARDED_PTR_REF(th->cfp->lfp[0]);
-
}} th->passed_block = blockptr;
retval = (*it_proc) (data1);