summaryrefslogtreecommitdiff
path: root/complex.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-14 18:02:02 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-14 20:42:10 +0900
commit5bd83909b961546ff6203ad088bfffeb8c19fceb (patch)
tree681b11c4e21eb7d3fb29253a10ca64ca9bd9ec42 /complex.c
parent1464f7a149264b02637fdd444f8a431f1692981a (diff)
downloadbundler-5bd83909b961546ff6203ad088bfffeb8c19fceb.tar.gz
Expand f_arg to use particular functions directly
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/complex.c b/complex.c
index c3e2fcc56d..bcdc486595 100644
--- a/complex.c
+++ b/complex.c
@@ -170,7 +170,27 @@ f_abs(VALUE x)
return rb_funcall(x, id_abs, 0);
}
-fun1(arg)
+static VALUE numeric_arg(VALUE self);
+static VALUE float_arg(VALUE self);
+
+inline static VALUE
+f_arg(VALUE x)
+{
+ if (RB_INTEGER_TYPE_P(x)) {
+ return numeric_arg(x);
+ }
+ else if (RB_FLOAT_TYPE_P(x)) {
+ return float_arg(x);
+ }
+ else if (RB_TYPE_P(x, T_RATIONAL)) {
+ return numeric_arg(x);
+ }
+ else if (RB_TYPE_P(x, T_COMPLEX)) {
+ return rb_complex_arg(x);
+ }
+ return rb_funcall(x, id_arg, 0);
+}
+
fun1(denominator)
inline static VALUE