summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-01-08 06:05:08 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-01-08 06:05:08 +0000
commit17065d47a68eaa6a854297b94e4d85d379b23f2d (patch)
tree670a5d87beb9be1833869225ce4722607327f4ba /range.c
parenta89ac45548573342400a563b407f13a8d5b06841 (diff)
downloadbundler-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.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/range.c b/range.c
index 3b56ee7d0b..2faf2f3489 100644
--- a/range.c
+++ b/range.c
@@ -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];