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
This commit is contained in:
parent
7c451099f5
commit
975e0ef858
24
complex.c
24
complex.c
@ -187,21 +187,17 @@ f_negative_p(VALUE x)
|
|||||||
|
|
||||||
#define f_positive_p(x) (!f_negative_p(x))
|
#define f_positive_p(x) (!f_negative_p(x))
|
||||||
|
|
||||||
inline static VALUE
|
inline static int
|
||||||
f_zero_p(VALUE x)
|
f_zero_p(VALUE x)
|
||||||
{
|
{
|
||||||
if (FIXNUM_P(x)) {
|
if (RB_INTEGER_TYPE_P(x)) {
|
||||||
return f_boolcast(FIXNUM_ZERO_P(x));
|
return FIXNUM_ZERO_P(x);
|
||||||
}
|
|
||||||
else if (RB_TYPE_P(x, T_BIGNUM)) {
|
|
||||||
return Qfalse;
|
|
||||||
}
|
}
|
||||||
else if (RB_TYPE_P(x, T_RATIONAL)) {
|
else if (RB_TYPE_P(x, T_RATIONAL)) {
|
||||||
VALUE num = RRATIONAL(x)->num;
|
const VALUE num = RRATIONAL(x)->num;
|
||||||
|
return FIXNUM_ZERO_P(num);
|
||||||
return f_boolcast(FIXNUM_P(num) && 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))
|
#define f_nonzero_p(x) (!f_zero_p(x))
|
||||||
@ -738,10 +734,10 @@ rb_complex_mul(VALUE self, VALUE other)
|
|||||||
|
|
||||||
get_dat2(self, other);
|
get_dat2(self, other);
|
||||||
|
|
||||||
arzero = !!f_zero_p(areal = adat->real);
|
arzero = f_zero_p(areal = adat->real);
|
||||||
aizero = !!f_zero_p(aimag = adat->imag);
|
aizero = f_zero_p(aimag = adat->imag);
|
||||||
brzero = !!f_zero_p(breal = bdat->real);
|
brzero = f_zero_p(breal = bdat->real);
|
||||||
bizero = !!f_zero_p(bimag = bdat->imag);
|
bizero = f_zero_p(bimag = bdat->imag);
|
||||||
real = f_sub(safe_mul(areal, breal, arzero, brzero),
|
real = f_sub(safe_mul(areal, breal, arzero, brzero),
|
||||||
safe_mul(aimag, bimag, aizero, bizero));
|
safe_mul(aimag, bimag, aizero, bizero));
|
||||||
imag = f_add(safe_mul(areal, bimag, arzero, bizero),
|
imag = f_add(safe_mul(areal, bimag, arzero, bizero),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user