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

ruby-changes:56905

From: Nobuyoshi <ko1@a...>
Date: Sat, 10 Aug 2019 14:26:30 +0900 (JST)
Subject: [ruby-changes:56905] Nobuyoshi Nakada: 98c22c78e4 (master): Expanded f_real_p

https://git.ruby-lang.org/ruby.git/commit/?id=98c22c78e4

From 98c22c78e40d84678e7bac187236e049e9d8c211 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sat, 10 Aug 2019 13:56:18 +0900
Subject: Expanded f_real_p


diff --git a/complex.c b/complex.c
index 4c51d1a..ed35b2b 100644
--- a/complex.c
+++ b/complex.c
@@ -235,7 +235,25 @@ f_negate(VALUE x) https://github.com/ruby/ruby/blob/trunk/complex.c#L235
     return rb_funcall(x, id_negate, 0);
 }
 
-fun1(real_p)
+static VALUE nucomp_real_p(VALUE self);
+
+static inline bool
+f_real_p(VALUE x)
+{
+    if (RB_INTEGER_TYPE_P(x)) {
+        return TRUE;
+    }
+    else if (RB_FLOAT_TYPE_P(x)) {
+        return TRUE;
+    }
+    else if (RB_TYPE_P(x, T_RATIONAL)) {
+        return TRUE;
+    }
+    else if (RB_TYPE_P(x, T_COMPLEX)) {
+        return nucomp_real_p(x);
+    }
+    return rb_funcall(x, id_real_p, 0);
+}
 
 inline static VALUE
 f_to_i(VALUE x)
@@ -244,6 +262,7 @@ f_to_i(VALUE x) https://github.com/ruby/ruby/blob/trunk/complex.c#L262
 	return rb_str_to_inum(x, 10, 0);
     return rb_funcall(x, id_to_i, 0);
 }
+
 inline static VALUE
 f_to_f(VALUE x)
 {
@@ -1090,7 +1109,8 @@ nucomp_cmp(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/complex.c#L1109
         if (RB_TYPE_P(other, T_COMPLEX) && nucomp_real_p(other)) {
             get_dat2(self, other);
             return rb_funcall(adat->real, idCmp, 1, bdat->real);
-        } else if (f_real_p(other)) {
+        }
+        else if (f_real_p(other)) {
             get_dat1(self);
             return rb_funcall(dat->real, idCmp, 1, other);
         }
-- 
cgit v0.10.2


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

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