ruby-changes:56483
From: Nobuyoshi <ko1@a...>
Date: Sun, 14 Jul 2019 20:43:17 +0900 (JST)
Subject: [ruby-changes:56483] Nobuyoshi Nakada: 1464f7a149 (master): Expand f_abs to use particular functions directly
https://git.ruby-lang.org/ruby.git/commit/?id=1464f7a149 From 1464f7a149264b02637fdd444f8a431f1692981a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sun, 14 Jul 2019 18:01:24 +0900 Subject: Expand f_abs to use particular functions directly diff --git a/complex.c b/complex.c index 44fd657..c3e2fcc 100644 --- a/complex.c +++ b/complex.c @@ -152,7 +152,24 @@ f_sub(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/complex.c#L152 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(denominator) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/