8000 Enumerator::Lazy optimized using Procs chaining by gregolsen · Pull Request #150 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

Enumerator::Lazy optimized using Procs chaining #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 17 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
rb_funcall changed to rb_proc_call_with_block for speed up
  • Loading branch information
gregolsen committed Jul 31, 2012
commit 30f11469511f6ae56e980d92b24c77b53996f079
18 changes: 6 additions & 12 deletions enumerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1160,12 +1160,10 @@ process_element(VALUE procs_array, VALUE yielder, int argc, VALUE* argv)
if (RTEST(move_next)) {
switch ((enum proc_entry_type) entry->type) {
case T_PROC_MAP:
result = rb_funcall(entry->proc, rb_intern("call"),
1, result);
result = rb_proc_call_with_block(entry->proc, 1, &result, Qnil);
break;
case T_PROC_SELECT:
move_next = rb_funcall(entry->proc, rb_intern("call"),
1, result);
move_next = rb_proc_call_with_block(entry->proc, 1, &result, Qnil);
break;
case T_PROC_TAKE:
memo = RNODE(entry->memo);
Expand All @@ -1184,28 +1182,24 @@ process_element(VALUE procs_array, VALUE yielder, int argc, VALUE* argv)
}
break;
case T_PROC_TAKE_WHILE:
move_next = rb_funcall(entry->proc, rb_intern("call"),
1, result);
move_next = rb_proc_call_with_block(entry->proc, 1, &result, Qnil);
if (!RTEST(move_next)) result = Qundef;
break;
case T_PROC_DROP_WHILE:
memo = RNODE(entry->memo);
if (!memo->u3.state) {
move_next = !RTEST(rb_funcall(entry->proc,
rb_intern("call"), 1, result));
move_next = !RTEST(rb_proc_call_with_block(entry->proc, 1, &result, Qnil));
if (move_next) memo->u3.state = TRUE;
}
break;
case T_PROC_REJECT:
move_next = !RTEST(rb_funcall(entry->proc, rb_intern("call"),
1, result));
move_next = !RTEST(rb_proc_call_with_block(entry->proc, 1, &result, Qnil));
break;
case T_PROC_GREP:
move_next = rb_funcall(entry->memo, id_eqq, 1, result);

if (RTEST(move_next) && entry->proc) {
result = rb_funcall(entry->proc,
rb_intern("call"), 1, result);
result = rb_proc_call_with_block(entry->proc, 1, &result, Qnil);
}
break;
}
Expand Down
0