aboutsummaryrefslogtreecommitdiffstats
path: root/complex.c
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-13 16:22:08 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-13 16:22:08 +0000
commit3e3318112f94b7d59eb57f7e28800a1b5290ae6b (patch)
tree69e553617b593756c00523ac529ed50cb3b04dc5 /complex.c
parentf6dcab543f65537dc61f088545741d05b5e0d518 (diff)
downloadruby-3e3318112f94b7d59eb57f7e28800a1b5290ae6b.tar.gz
complex.c: refactoring and small optimization
* complex.c (nucomp_expt): optimize the access to the numerator and denominator of a rational number. * complex.c (k_rational_p): removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/complex.c b/complex.c
index 11171e3e02..e2a7efb262 100644
--- a/complex.c
+++ b/complex.c
@@ -237,12 +237,6 @@ k_numeric_p(VALUE x)
return f_kind_of_p(x, rb_cNumeric);
}
-
-inline static VALUE
-k_rational_p(VALUE x)
-{
- return f_kind_of_p(x, rb_cRational);
-}
#define k_exact_p(x) (!RB_FLOAT_TYPE_P(x))
#define k_exact_zero_p(x) (k_exact_p(x) && f_zero_p(x))
@@ -895,8 +889,8 @@ nucomp_expt(VALUE self, VALUE other)
if (k_numeric_p(other) && k_exact_zero_p(other))
return f_complex_new_bang1(CLASS_OF(self), ONE);
- if (k_rational_p(other) && f_one_p(f_denominator(other)))
- other = f_numerator(other); /* c14n */
+ if (RB_TYPE_P(other, T_RATIONAL) && RRATIONAL(other)->den == LONG2FIX(1))
+ other = RRATIONAL(other)->num; /* c14n */
if (RB_TYPE_P(other, T_COMPLEX)) {
get_dat1(other);