[前][次][番号順一覧][スレッド一覧]

ruby-changes:56484

From: Nobuyoshi <ko1@a...>
Date: Sun, 14 Jul 2019 20:43:18 +0900 (JST)
Subject: [ruby-changes:56484] Nobuyoshi Nakada: 5bd83909b9 (master): Expand f_arg to use particular functions directly

https://git.ruby-lang.org/ruby.git/commit/?id=5bd83909b9

From 5bd83909b961546ff6203ad088bfffeb8c19fceb Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 14 Jul 2019 18:02:02 +0900
Subject: Expand f_arg to use particular functions directly


diff --git a/complex.c b/complex.c
index c3e2fcc..bcdc486 100644
--- a/complex.c
+++ b/complex.c
@@ -170,7 +170,27 @@ f_abs(VALUE x) https://github.com/ruby/ruby/blob/trunk/complex.c#L170
     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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]