Expand f_abs to use particular functions directly
This commit is contained in:
parent
0df4a813ca
commit
1464f7a149
19
complex.c
19
complex.c
@ -152,7 +152,24 @@ f_sub(VALUE x, VALUE y)
|
|||||||
return rb_funcall(x, '-', 1, y);
|
return rb_funcall(x, '-', 1, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
fun1(abs)
|
inline static VALUE
|
||||||
|
f_abs(VALUE x)
|
||||||
|
{
|
||||||
|
if (RB_INTEGER_TYPE_P(x)) {
|
||||||
|
return rb_int_abs(x);
|
||||||
|
}
|
||||||
|
else if (RB_FLOAT_TYPE_P(x)) {
|
||||||
|
return rb_float_abs(x);
|
||||||
|
}
|
||||||
|
else if (RB_TYPE_P(x, T_RATIONAL)) {
|
||||||
|
return rb_rational_abs(x);
|
||||||
|
}
|
||||||
|
else if (RB_TYPE_P(x, T_COMPLEX)) {
|
||||||
|
return rb_complex_abs(x);
|
||||||
|
}
|
||||||
|
return rb_funcall(x, id_abs, 0);
|
||||||
|
}
|
||||||
|
|
||||||
fun1(arg)
|
fun1(arg)
|
||||||
fun1(denominator)
|
fun1(denominator)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user