diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-04 13:57:02 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-04 13:57:02 +0000 |
commit | 326e38164b1ec54925591434891a5c131b1d7b3d (patch) | |
tree | 7bbb5156c89122a011efa947b5510fcebfdecc99 | |
parent | dd95c9b1cdab684e10f5fe94c53334f35781b855 (diff) | |
download | ruby-326e38164b1ec54925591434891a5c131b1d7b3d.tar.gz |
numeric.c: split NUM_STEP_GET_INF
* numeric.c (NUM_STEP_GET_INF): split from NUM_STEP_SCAN_ARGS(), since
inf is not used in num_step_size().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | numeric.c | 15 |
2 files changed, 15 insertions, 5 deletions
@@ -1,3 +1,8 @@ +Wed Sep 4 22:56:49 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * numeric.c (NUM_STEP_GET_INF): split from NUM_STEP_SCAN_ARGS(), since + inf is not used in num_step_size(). + Wed Sep 4 20:22:43 2013 Tanaka Akira <akr@fsij.org> * bignum.c (bigdivrem_normal): Add assertions. @@ -1846,7 +1846,7 @@ ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl) } } -#define NUM_STEP_SCAN_ARGS(argc, argv, to, step, hash, desc, inf) do { \ +#define NUM_STEP_SCAN_ARGS(argc, argv, to, step, hash, desc) do { \ argc = rb_scan_args(argc, argv, "02:", &to, &step, &hash); \ if (!NIL_P(hash)) { \ step = rb_hash_aref(hash, sym_by); \ @@ -1878,7 +1878,10 @@ ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl) rb_raise(rb_eTypeError, "limit must be numeric"); \ } \ } \ - if (TYPE(to) == T_FLOAT) { \ +} while (0) + +#define NUM_STEP_GET_INF(to, desc, inf) do { \ + if (RB_TYPE_P(to, T_FLOAT)) { \ double f = RFLOAT_VALUE(to); \ inf = isinf(f) && (signbit(f) ? desc : !desc); \ } \ @@ -1889,11 +1892,11 @@ static VALUE num_step_size(VALUE from, VALUE args, VALUE eobj) { VALUE to, step, hash; - int desc, inf; + int desc; int argc = args ? RARRAY_LENINT(args) : 0; VALUE *argv = args ? RARRAY_PTR(args) : 0; - NUM_STEP_SCAN_ARGS(argc, argv, to, step, hash, desc, inf); + NUM_STEP_SCAN_ARGS(argc, argv, to, step, hash, desc); return ruby_num_interval_step_size(from, to, step, FALSE); } @@ -1959,7 +1962,9 @@ num_step(int argc, VALUE *argv, VALUE from) RETURN_SIZED_ENUMERATOR(from, argc, argv, num_step_size); - NUM_STEP_SCAN_ARGS(argc, argv, to, step, hash, desc, inf); + NUM_STEP_SCAN_ARGS(argc, argv, to, step, hash, desc); + NUM_STEP_GET_INF(to, desc, inf); + if (FIXNUM_P(from) && (inf || FIXNUM_P(to)) && FIXNUM_P(step)) { long i = FIX2LONG(from); |