diff options
author | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-13 16:43:43 +0000 |
---|---|---|
committer | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-13 16:43:43 +0000 |
commit | 975e0ef8581e7713fc316e71a7e96a0afb20bbae (patch) | |
tree | 8bb4512c055067670a465b2e62d6f8a329cd72b9 /complex.c | |
parent | 7c451099f532e60bf7920d8c689a84658d113d6d (diff) |
complex.c: refactoring
* complex.c (f_zero_p): return int rather than VALUE.
* complex.c (rb_complex_mul): remove needless negate operations.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'complex.c')
-rw-r--r-- | complex.c | 24 |
1 files changed, 10 insertions, 14 deletions
@@ -187,21 +187,17 @@ f_negative_p(VALUE x) #define f_positive_p(x) (!f_negative_p(x)) -inline static VALUE +inline static int f_zero_p(VALUE x) { - if (FIXNUM_P(x)) { - return f_boolcast(FIXNUM_ZERO_P(x)); - } - else if (RB_TYPE_P(x, T_BIGNUM)) { - return Qfalse; + if (RB_INTEGER_TYPE_P(x)) { + return FIXNUM_ZERO_P(x); } else if (RB_TYPE_P(x, T_RATIONAL)) { - VALUE num = RRATIONAL(x)->num; - - return f_boolcast(FIXNUM_P(num) && FIXNUM_ZERO_P(num)); + const VALUE num = RRATIONAL(x)->num; + return FIXNUM_ZERO_P(num); } - return rb_funcall(x, id_eqeq_p, 1, ZERO); + return (int)rb_equal(x, ZERO); } #define f_nonzero_p(x) (!f_zero_p(x)) @@ -738,10 +734,10 @@ rb_complex_mul(VALUE self, VALUE other) get_dat2(self, other); - arzero = !!f_zero_p(areal = adat->real); - aizero = !!f_zero_p(aimag = adat->imag); - brzero = !!f_zero_p(breal = bdat->real); - bizero = !!f_zero_p(bimag = bdat->imag); + arzero = f_zero_p(areal = adat->real); + aizero = f_zero_p(aimag = adat->imag); + brzero = f_zero_p(breal = bdat->real); + bizero = f_zero_p(bimag = bdat->imag); real = f_sub(safe_mul(areal, breal, arzero, brzero), safe_mul(aimag, bimag, aizero, bizero)); imag = f_add(safe_mul(areal, bimag, arzero, bizero), |