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
This commit is contained in:
parent
9b7d28af8e
commit
912857340b
10
complex.c
10
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user