ruby-changes:67181
From: S.H <ko1@a...>
Date: Wed, 18 Aug 2021 02:25:36 +0900 (JST)
Subject: [ruby-changes:67181] 58bd943436 (master): Replace f_boolcast with RBOOL macro
https://git.ruby-lang.org/ruby.git/commit/?id=58bd943436 From 58bd9434360d5a46974eaa03139893c0145615dc Mon Sep 17 00:00:00 2001 From: "S.H" <gamelinks007@g...> Date: Wed, 18 Aug 2021 02:25:19 +0900 Subject: Replace f_boolcast with RBOOL macro * Move f_boolcast definination * Remove f_boolcast macro defination * to --- complex.c | 10 ++++------ math.c | 5 ++--- rational.c | 11 +++++------ 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/complex.c b/complex.c index 09e47f8..f0dfd2a 100644 --- a/complex.c +++ b/complex.c @@ -54,8 +54,6 @@ static ID id_abs, id_arg, https://github.com/ruby/ruby/blob/trunk/complex.c#L54 #define id_quo idQuo #define id_fdiv idFdiv -#define f_boolcast(x) ((x) ? Qtrue : Qfalse) - #define fun1(n) \ inline static VALUE \ f_##n(VALUE x)\ @@ -1092,15 +1090,15 @@ nucomp_eqeq_p(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/complex.c#L1090 if (RB_TYPE_P(other, T_COMPLEX)) { get_dat2(self, other); - return f_boolcast(f_eqeq_p(adat->real, bdat->real) && + return RBOOL(f_eqeq_p(adat->real, bdat->real) && f_eqeq_p(adat->imag, bdat->imag)); } if (k_numeric_p(other) && f_real_p(other)) { get_dat1(self); - return f_boolcast(f_eqeq_p(dat->real, other) && f_zero_p(dat->imag)); + return RBOOL(f_eqeq_p(dat->real, other) && f_zero_p(dat->imag)); } - return f_boolcast(f_eqeq_p(other, self)); + return RBOOL(f_eqeq_p(other, self)); } static bool @@ -1354,7 +1352,7 @@ nucomp_eql_p(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/complex.c#L1352 if (RB_TYPE_P(other, T_COMPLEX)) { get_dat2(self, other); - return f_boolcast((CLASS_OF(adat->real) == CLASS_OF(bdat->real)) && + return RBOOL((CLASS_OF(adat->real) == CLASS_OF(bdat->real)) && (CLASS_OF(adat->imag) == CLASS_OF(bdat->imag)) && f_eqeq_p(self, other)); diff --git a/math.c b/math.c index f0237d4..dd98d88 100644 --- a/math.c +++ b/math.c @@ -620,12 +620,11 @@ math_sqrt(VALUE unused_obj, VALUE x) https://github.com/ruby/ruby/blob/trunk/math.c#L620 return rb_math_sqrt(x); } -#define f_boolcast(x) ((x) ? Qtrue : Qfalse) inline static VALUE f_negative_p(VALUE x) { if (FIXNUM_P(x)) - return f_boolcast(FIX2LONG(x) < 0); + return RBOOL(FIX2LONG(x) < 0); return rb_funcall(x, '<', 1, INT2FIX(0)); } inline static VALUE @@ -633,7 +632,7 @@ f_signbit(VALUE x) https://github.com/ruby/ruby/blob/trunk/math.c#L632 { if (RB_TYPE_P(x, T_FLOAT)) { double f = RFLOAT_VALUE(x); - return f_boolcast(!isnan(f) && signbit(f)); + return RBOOL(!isnan(f) && signbit(f)); } return f_negative_p(x); } diff --git a/rational.c b/rational.c index 7324f78..88693d9 100644 --- a/rational.c +++ b/rational.c @@ -46,7 +46,6 @@ static ID id_abs, id_integer_p, https://github.com/ruby/ruby/blob/trunk/rational.c#L46 #define id_idiv idDiv #define id_to_i idTo_i -#define f_boolcast(x) ((x) ? Qtrue : Qfalse) #define f_inspect rb_inspect #define f_to_s rb_obj_as_string @@ -1136,12 +1135,12 @@ nurat_eqeq_p(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/rational.c#L1135 } else { const double d = nurat_to_double(self); - return f_boolcast(FIXNUM_ZERO_P(rb_dbl_cmp(d, NUM2DBL(other)))); + return RBOOL(FIXNUM_ZERO_P(rb_dbl_cmp(d, NUM2DBL(other)))); } } else if (RB_FLOAT_TYPE_P(other)) { const double d = nurat_to_double(self); - return f_boolcast(FIXNUM_ZERO_P(rb_dbl_cmp(d, RFLOAT_VALUE(other)))); + return RBOOL(FIXNUM_ZERO_P(rb_dbl_cmp(d, RFLOAT_VALUE(other)))); } else if (RB_TYPE_P(other, T_RATIONAL)) { { @@ -1150,7 +1149,7 @@ nurat_eqeq_p(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/rational.c#L1149 if (INT_ZERO_P(adat->num) && INT_ZERO_P(bdat->num)) return Qtrue; - return f_boolcast(rb_int_equal(adat->num, bdat->num) && + return RBOOL(rb_int_equal(adat->num, bdat->num) && rb_int_equal(adat->den, bdat->den)); } } @@ -1201,7 +1200,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/rational.c#L1200 nurat_positive_p(VALUE self) { get_dat1(self); - return f_boolcast(INT_POSITIVE_P(dat->num)); + return RBOOL(INT_POSITIVE_P(dat->num)); } /* @@ -1214,7 +1213,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/rational.c#L1213 nurat_negative_p(VALUE self) { get_dat1(self); - return f_boolcast(INT_NEGATIVE_P(dat->num)); + return RBOOL(INT_NEGATIVE_P(dat->num)); } /* -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/