diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-01-08 06:05:08 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-01-08 06:05:08 +0000 |
commit | 17065d47a68eaa6a854297b94e4d85d379b23f2d (patch) | |
tree | 670a5d87beb9be1833869225ce4722607327f4ba /range.c | |
parent | a89ac45548573342400a563b407f13a8d5b06841 (diff) | |
download | bundler-17065d47a68eaa6a854297b94e4d85d379b23f2d.tar.gz |
* range.c (range_each): treat fixnums specially to boost.
* numeric.c (num_step): remove rb_scan_args() for small speedup.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'range.c')
-rw-r--r-- | range.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -306,7 +306,16 @@ range_each(range) rb_raise(rb_eTypeError, "cannot iterate from %s", rb_class2name(CLASS_OF(beg))); } - if (TYPE(beg) == T_STRING) { + if (FIXNUM_P(beg) && FIXNUM_P(end)) { /* fixnums are special */ + long lim = FIX2LONG(end); + long i; + + if (!EXCL(range)) lim += 1; + for (i=FIX2LONG(beg); i<lim; i++) { + rb_yield(LONG2NUM(i)); + } + } + else if (TYPE(beg) == T_STRING) { VALUE args[5]; long iter[2]; |