From 5bd83909b961546ff6203ad088bfffeb8c19fceb Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 14 Jul 2019 18:02:02 +0900 Subject: [PATCH] Expand f_arg to use particular functions directly --- complex.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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