Skip to content

Commit

Permalink
* vm_eval.c, internal.h (rb_yield_1): added for performance which
Browse files Browse the repository at this point in the history
  doesn't check Qundef.
* numeric.c (int_dotimes): use rb_yield_1.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
ko1 committed Oct 10, 2015
1 parent ad45aea commit 0a40bcb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
@@ -1,3 +1,10 @@
Sun Oct 11 06:21:50 2015 Koichi Sasada <ko1@atdot.net>

* vm_eval.c, internal.h (rb_yield_1): added for performance which
doesn't check Qundef.

* numeric.c (int_dotimes): use rb_yield_1.

Sun Oct 11 06:19:49 2015 Koichi Sasada <ko1@atdot.net>

* vm_insnhelper.c (vm_call_iseq_setup_normal): setup sp first
Expand Down
1 change: 1 addition & 0 deletions internal.h
Expand Up @@ -1192,6 +1192,7 @@ typedef void rb_check_funcall_hook(int, VALUE, ID, int, const VALUE *, VALUE);
VALUE rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv,
rb_check_funcall_hook *hook, VALUE arg);
VALUE rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, int *stateptr);
VALUE rb_yield_1(VALUE val);

/* vm_insnhelper.c */
VALUE rb_equal_opt(VALUE obj1, VALUE obj2);
Expand Down
2 changes: 1 addition & 1 deletion numeric.c
Expand Up @@ -3949,7 +3949,7 @@ int_dotimes(VALUE num)

end = FIX2LONG(num);
for (i=0; i<end; i++) {
rb_yield(LONG2FIX(i));
rb_yield_1(LONG2FIX(i));
}
}
else {
Expand Down
8 changes: 7 additions & 1 deletion vm_eval.c
Expand Up @@ -999,14 +999,20 @@ rb_yield_0(int argc, const VALUE * argv)
return vm_yield(GET_THREAD(), argc, argv);
}

VALUE
rb_yield_1(VALUE val)
{
return rb_yield_0(1, &val);
}

VALUE
rb_yield(VALUE val)
{
if (val == Qundef) {
return rb_yield_0(0, 0);
}
else {
return rb_yield_0(1, &val);
return rb_yield_1(val);
}
}

Expand Down

0 comments on commit 0a40bcb

Please sign in to comment.