mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* vm_eval.c (rb_iterate): pass current block when the argument bl_proc
is NULL. This behavior can be used to make enumerator faster [ruby-dev:39874] * enumerator.c (enumerator_each): pass current block directly instead of trampoline block (enumerator_each_i). * io.c (argf_each_line, argf_each_byte, argf_each_char): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0208837f08
commit
ae8dc9b722
4 changed files with 26 additions and 17 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
Sun Dec 20 21:26:05 2009 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
|
* vm_eval.c (rb_iterate): pass current block when the argument bl_proc
|
||||||
|
is NULL. This behavior can be used to make enumerator faster
|
||||||
|
[ruby-dev:39874]
|
||||||
|
|
||||||
|
* enumerator.c (enumerator_each): pass current block directly instead
|
||||||
|
of trampoline block (enumerator_each_i).
|
||||||
|
|
||||||
|
* io.c (argf_each_line, argf_each_byte, argf_each_char): ditto.
|
||||||
|
|
||||||
Sat Dec 19 14:59:30 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Sat Dec 19 14:59:30 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* gem_prelude.rb (Kernel#gem): should make gem private. a patch
|
* gem_prelude.rb (Kernel#gem): should make gem private. a patch
|
||||||
|
|
|
@ -329,12 +329,6 @@ enumerator_allocate(VALUE klass)
|
||||||
return enum_obj;
|
return enum_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
|
||||||
enumerator_each_i(VALUE v, VALUE enum_obj, int argc, VALUE *argv)
|
|
||||||
{
|
|
||||||
return rb_yield_values2(argc, argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, VALUE *argv)
|
enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, VALUE *argv)
|
||||||
{
|
{
|
||||||
|
@ -473,7 +467,7 @@ static VALUE
|
||||||
enumerator_each(VALUE obj)
|
enumerator_each(VALUE obj)
|
||||||
{
|
{
|
||||||
if (!rb_block_given_p()) return 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
|
static VALUE
|
||||||
|
|
6
io.c
6
io.c
|
@ -9148,7 +9148,7 @@ argf_each_line(int argc, VALUE *argv, VALUE argf)
|
||||||
RETURN_ENUMERATOR(argf, argc, argv);
|
RETURN_ENUMERATOR(argf, argc, argv);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (!next_argv()) return argf;
|
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;
|
ARGF.next_p = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9182,7 +9182,7 @@ argf_each_byte(VALUE argf)
|
||||||
RETURN_ENUMERATOR(argf, 0, 0);
|
RETURN_ENUMERATOR(argf, 0, 0);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (!next_argv()) return argf;
|
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;
|
ARGF.next_p = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9212,7 +9212,7 @@ argf_each_char(VALUE argf)
|
||||||
RETURN_ENUMERATOR(argf, 0, 0);
|
RETURN_ENUMERATOR(argf, 0, 0);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (!next_argv()) return argf;
|
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;
|
ARGF.next_p = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
18
vm_eval.c
18
vm_eval.c
|
@ -820,20 +820,24 @@ rb_iterate(VALUE (* it_proc) (VALUE), VALUE data1,
|
||||||
{
|
{
|
||||||
int state;
|
int state;
|
||||||
volatile VALUE retval = Qnil;
|
volatile VALUE retval = Qnil;
|
||||||
NODE *node = NEW_IFUNC(bl_proc, data2);
|
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
rb_control_frame_t *volatile cfp = th->cfp;
|
rb_control_frame_t *volatile cfp = th->cfp;
|
||||||
|
rb_block_t *blockptr;
|
||||||
|
|
||||||
|
if (bl_proc) {
|
||||||
|
blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(th->cfp);
|
||||||
|
blockptr->iseq = (void *)NEW_IFUNC(bl_proc, data2);
|
||||||
|
blockptr->proc = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
blockptr = GC_GUARDED_PTR_REF(th->cfp->lfp[0]);
|
||||||
|
}
|
||||||
|
*(rb_block_t *volatile *)&blockptr = blockptr;
|
||||||
TH_PUSH_TAG(th);
|
TH_PUSH_TAG(th);
|
||||||
state = TH_EXEC_TAG();
|
state = TH_EXEC_TAG();
|
||||||
if (state == 0) {
|
if (state == 0) {
|
||||||
iter_retry:
|
iter_retry:
|
||||||
{
|
th->passed_block = *(rb_block_t *volatile *)&blockptr;
|
||||||
rb_block_t *blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(th->cfp);
|
|
||||||
blockptr->iseq = (void *)node;
|
|
||||||
blockptr->proc = 0;
|
|
||||||
th->passed_block = blockptr;
|
|
||||||
}
|
|
||||||
retval = (*it_proc) (data1);
|
retval = (*it_proc) (data1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in a new issue