mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* range.c (range_each): check #succ only when it is really
needed. small performance improvement. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
20f4628169
commit
e69f212933
2 changed files with 9 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Feb 24 00:24:13 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* range.c (range_each): check #succ only when it is really
|
||||||
|
needed. small performance improvement.
|
||||||
|
|
||||||
Tue Feb 24 00:19:33 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Tue Feb 24 00:19:33 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* lib/pathname.rb (Pathname#foreachline): removed wrongly
|
* lib/pathname.rb (Pathname#foreachline): removed wrongly
|
||||||
|
|
8
range.c
8
range.c
|
@ -417,10 +417,6 @@ range_each(VALUE range)
|
||||||
beg = RANGE_BEG(range);
|
beg = RANGE_BEG(range);
|
||||||
end = RANGE_END(range);
|
end = RANGE_END(range);
|
||||||
|
|
||||||
if (!rb_respond_to(beg, id_succ)) {
|
|
||||||
rb_raise(rb_eTypeError, "can't iterate from %s",
|
|
||||||
rb_obj_classname(beg));
|
|
||||||
}
|
|
||||||
if (FIXNUM_P(beg) && FIXNUM_P(end)) { /* fixnums are special */
|
if (FIXNUM_P(beg) && FIXNUM_P(end)) { /* fixnums are special */
|
||||||
long lim = FIX2LONG(end);
|
long lim = FIX2LONG(end);
|
||||||
long i;
|
long i;
|
||||||
|
@ -439,6 +435,10 @@ range_each(VALUE range)
|
||||||
rb_block_call(beg, rb_intern("upto"), 2, args, rb_yield, 0);
|
rb_block_call(beg, rb_intern("upto"), 2, args, rb_yield, 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (!rb_respond_to(beg, id_succ)) {
|
||||||
|
rb_raise(rb_eTypeError, "can't iterate from %s",
|
||||||
|
rb_obj_classname(beg));
|
||||||
|
}
|
||||||
range_each_func(range, each_i, NULL);
|
range_each_func(range, each_i, NULL);
|
||||||
}
|
}
|
||||||
return range;
|
return range;
|
||||||
|
|
Loading…
Reference in a new issue