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

ruby-changes:69665

From: S.H <ko1@a...>
Date: Tue, 9 Nov 2021 17:09:41 +0900 (JST)
Subject: [ruby-changes:69665] 75aae66c4f (master): Some codes replace to `RBOOL` macro (#5023)

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

From 75aae66c4f3eacd527cea71e0c8e486b630fc0a4 Mon Sep 17 00:00:00 2001
From: "S.H" <gamelinks007@g...>
Date: Tue, 9 Nov 2021 17:09:29 +0900
Subject: Some codes replace to `RBOOL` macro (#5023)

* Some code replace and using RBOOL macro

* Fix indent

* Using RBOOL in syserr_eqq function
---
 error.c   |  4 +---
 process.c | 20 ++++----------------
 range.c   |  6 ++----
 thread.c  |  7 +------
 4 files changed, 8 insertions(+), 29 deletions(-)

diff --git a/error.c b/error.c
index f9433ebe501..926ec5adb9d 100644
--- a/error.c
+++ b/error.c
@@ -2421,9 +2421,7 @@ syserr_eqq(VALUE self, VALUE exc) https://github.com/ruby/ruby/blob/trunk/error.c#L2421
 	num = rb_funcallv(exc, id_errno, 0, 0);
     }
     e = rb_const_get(self, id_Errno);
-    if (FIXNUM_P(num) ? num == e : rb_equal(num, e))
-	return Qtrue;
-    return Qfalse;
+    return RBOOL(FIXNUM_P(num) ? num == e : rb_equal(num, e));
 }
 
 
diff --git a/process.c b/process.c
index 6b837677381..818b0257d4e 100644
--- a/process.c
+++ b/process.c
@@ -898,10 +898,7 @@ pst_wifstopped(VALUE st) https://github.com/ruby/ruby/blob/trunk/process.c#L898
 {
     int status = PST2INT(st);
 
-    if (WIFSTOPPED(status))
-	return Qtrue;
-    else
-	return Qfalse;
+    return RBOOL(WIFSTOPPED(status));
 }
 
 
@@ -937,10 +934,7 @@ pst_wifsignaled(VALUE st) https://github.com/ruby/ruby/blob/trunk/process.c#L934
 {
     int status = PST2INT(st);
 
-    if (WIFSIGNALED(status))
-	return Qtrue;
-    else
-	return Qfalse;
+    return RBOOL(WIFSIGNALED(status));
 }
 
 
@@ -978,10 +972,7 @@ pst_wifexited(VALUE st) https://github.com/ruby/ruby/blob/trunk/process.c#L972
 {
     int status = PST2INT(st);
 
-    if (WIFEXITED(status))
-	return Qtrue;
-    else
-	return Qfalse;
+    return RBOOL(WIFEXITED(status));
 }
 
 
@@ -1047,10 +1038,7 @@ pst_wcoredump(VALUE st) https://github.com/ruby/ruby/blob/trunk/process.c#L1038
 #ifdef WCOREDUMP
     int status = PST2INT(st);
 
-    if (WCOREDUMP(status))
-	return Qtrue;
-    else
-	return Qfalse;
+    return RBOOL(WCOREDUMP(status));
 #else
     return Qfalse;
 #endif
diff --git a/range.c b/range.c
index e49dd2cf355..6ac7d794c65 100644
--- a/range.c
+++ b/range.c
@@ -1792,14 +1792,12 @@ range_include_internal(VALUE range, VALUE val, int string_use_cover) https://github.com/ruby/ruby/blob/trunk/range.c#L1792
         else if (NIL_P(beg)) {
 	    VALUE r = rb_funcall(val, id_cmp, 1, end);
 	    if (NIL_P(r)) return Qfalse;
-	    if (rb_cmpint(r, val, end) <= 0) return Qtrue;
-	    return Qfalse;
+            return RBOOL(rb_cmpint(r, val, end) <= 0);
         }
 	else if (NIL_P(end)) {
 	    VALUE r = rb_funcall(beg, id_cmp, 1, val);
 	    if (NIL_P(r)) return Qfalse;
-	    if (rb_cmpint(r, beg, val) <= 0) return Qtrue;
-	    return Qfalse;
+            return RBOOL(rb_cmpint(r, beg, val) <= 0);
 	}
     }
     return Qundef;
diff --git a/thread.c b/thread.c
index 251dc1b3450..36723c6fc06 100644
--- a/thread.c
+++ b/thread.c
@@ -3326,12 +3326,7 @@ rb_thread_status(VALUE thread) https://github.com/ruby/ruby/blob/trunk/thread.c#L3326
 static VALUE
 rb_thread_alive_p(VALUE thread)
 {
-    if (thread_finished(rb_thread_ptr(thread))) {
-        return Qfalse;
-    }
-    else {
-        return Qtrue;
-    }
+    return RBOOL(!thread_finished(rb_thread_ptr(thread)));
 }
 
 /*
-- 
cgit v1.2.1


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

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