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

ruby-changes:73375

From: Nobuyoshi <ko1@a...>
Date: Fri, 2 Sep 2022 14:33:48 +0900 (JST)
Subject: [ruby-changes:73375] a9b59e24f4 (master): Turn `f_zero_p` to `bool`

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

From a9b59e24f49f669f6ad2f3238c4c518027a7f72d Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 31 Aug 2022 10:59:05 +0900
Subject: Turn `f_zero_p` to `bool`

---
 complex.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/complex.c b/complex.c
index ae40fa7355..1feafa370b 100644
--- a/complex.c
+++ b/complex.c
@@ -316,7 +316,7 @@ f_negative_p(VALUE x) https://github.com/ruby/ruby/blob/trunk/complex.c#L316
 
 #define f_positive_p(x) (!f_negative_p(x))
 
-inline static int
+inline static bool
 f_zero_p(VALUE x)
 {
     if (RB_FLOAT_TYPE_P(x)) {
@@ -329,7 +329,7 @@ f_zero_p(VALUE x) https://github.com/ruby/ruby/blob/trunk/complex.c#L329
         const VALUE num = RRATIONAL(x)->num;
         return FIXNUM_ZERO_P(num);
     }
-    return (int)rb_equal(x, ZERO);
+    return rb_equal(x, ZERO) != 0;
 }
 
 #define f_nonzero_p(x) (!f_zero_p(x))
@@ -832,7 +832,7 @@ rb_complex_minus(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/complex.c#L832
 }
 
 static VALUE
-safe_mul(VALUE a, VALUE b, int az, int bz)
+safe_mul(VALUE a, VALUE b, bool az, bool bz)
 {
     double v;
     if (!az && bz && RB_FLOAT_TYPE_P(a) && (v = RFLOAT_VALUE(a), !isnan(v))) {
@@ -847,10 +847,10 @@ safe_mul(VALUE a, VALUE b, int az, int bz) https://github.com/ruby/ruby/blob/trunk/complex.c#L847
 static void
 comp_mul(VALUE areal, VALUE aimag, VALUE breal, VALUE bimag, VALUE *real, VALUE *imag)
 {
-    int arzero = f_zero_p(areal);
-    int aizero = f_zero_p(aimag);
-    int brzero = f_zero_p(breal);
-    int bizero = f_zero_p(bimag);
+    bool arzero = f_zero_p(areal);
+    bool aizero = f_zero_p(aimag);
+    bool brzero = f_zero_p(breal);
+    bool bizero = f_zero_p(bimag);
     *real = f_sub(safe_mul(areal, breal, arzero, brzero),
                   safe_mul(aimag, bimag, aizero, bizero));
     *imag = f_add(safe_mul(areal, bimag, arzero, bizero),
@@ -1101,7 +1101,7 @@ static bool https://github.com/ruby/ruby/blob/trunk/complex.c#L1101
 nucomp_real_p(VALUE self)
 {
     get_dat1(self);
-    return(f_zero_p(dat->imag) ? true : false);
+    return f_zero_p(dat->imag);
 }
 
 /*
-- 
cgit v1.2.1


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

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