ruby-changes:67952
From: S-H-GAMELINKS <ko1@a...>
Date: Sun, 12 Sep 2021 11:16:44 +0900 (JST)
Subject: [ruby-changes:67952] 83a5e2bb5c (master): Using RB_FLOAT_TYPE_P macro
https://git.ruby-lang.org/ruby.git/commit/?id=83a5e2bb5c From 83a5e2bb5c1b9f24b70dc30c50b5deb4d7232119 Mon Sep 17 00:00:00 2001 From: S-H-GAMELINKS <gamelinks007@g...> Date: Sat, 11 Sep 2021 09:56:59 +0900 Subject: Using RB_FLOAT_TYPE_P macro --- compile.c | 4 +-- enumerator.c | 2 +- math.c | 2 +- numeric.c | 80 ++++++++++++++++++++++++++++++------------------------------ object.c | 2 +- random.c | 4 +-- range.c | 2 +- 7 files changed, 48 insertions(+), 48 deletions(-) diff --git a/compile.c b/compile.c index 0569601..268bd8b 100644 --- a/compile.c +++ b/compile.c @@ -4551,7 +4551,7 @@ rb_node_case_when_optimizable_literal(const NODE *const node) https://github.com/ruby/ruby/blob/trunk/compile.c#L4551 case NODE_LIT: { VALUE v = node->nd_lit; double ival; - if (RB_TYPE_P(v, T_FLOAT) && + if (RB_FLOAT_TYPE_P(v) && modf(RFLOAT_VALUE(v), &ival) == 0.0) { return FIXABLE(ival) ? LONG2FIX((long)ival) : rb_dbl2big(ival); } @@ -12407,7 +12407,7 @@ ibf_dump_object_object(struct ibf_dump *dump, VALUE obj) https://github.com/ruby/ruby/blob/trunk/compile.c#L12407 if (SPECIAL_CONST_P(obj) && ! (SYMBOL_P(obj) || - RB_TYPE_P(obj, T_FLOAT))) { + RB_FLOAT_TYPE_P(obj))) { obj_header.special_const = TRUE; obj_header.frozen = TRUE; obj_header.internal = TRUE; diff --git a/enumerator.c b/enumerator.c index 3ada2b0..0dc804a 100644 --- a/enumerator.c +++ b/enumerator.c @@ -3187,7 +3187,7 @@ enum_chain_total_size(VALUE enums) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L3187 for (i = 0; i < RARRAY_LEN(enums); i++) { VALUE size = enum_size(RARRAY_AREF(enums, i)); - if (NIL_P(size) || (RB_TYPE_P(size, T_FLOAT) && isinf(NUM2DBL(size)))) { + if (NIL_P(size) || (RB_FLOAT_TYPE_P(size) && isinf(NUM2DBL(size)))) { return size; } if (!RB_INTEGER_TYPE_P(size)) { diff --git a/math.c b/math.c index dd45caf..cce29b5 100644 --- a/math.c +++ b/math.c @@ -623,7 +623,7 @@ f_negative_p(VALUE x) https://github.com/ruby/ruby/blob/trunk/math.c#L623 inline static VALUE f_signbit(VALUE x) { - if (RB_TYPE_P(x, T_FLOAT)) { + if (RB_FLOAT_TYPE_P(x)) { double f = RFLOAT_VALUE(x); return RBOOL(!isnan(f) && signbit(f)); } diff --git a/numeric.c b/numeric.c index 7616c2b..39c2bd7 100644 --- a/numeric.c +++ b/numeric.c @@ -656,7 +656,7 @@ num_remainder(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L656 rb_num_positive_int_p(y)) || (rb_num_positive_int_p(x) && rb_num_negative_int_p(y)))) { - if (RB_TYPE_P(y, T_FLOAT)) { + if (RB_FLOAT_TYPE_P(y)) { if (isinf(RFLOAT_VALUE(y))) { return x; } @@ -1000,7 +1000,7 @@ rb_float_plus(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1000 else if (RB_BIGNUM_TYPE_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) + rb_big2dbl(y)); } - else if (RB_TYPE_P(y, T_FLOAT)) { + else if (RB_FLOAT_TYPE_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) + RFLOAT_VALUE(y)); } else { @@ -1024,7 +1024,7 @@ rb_float_minus(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1024 else if (RB_BIGNUM_TYPE_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) - rb_big2dbl(y)); } - else if (RB_TYPE_P(y, T_FLOAT)) { + else if (RB_FLOAT_TYPE_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) - RFLOAT_VALUE(y)); } else { @@ -1048,7 +1048,7 @@ rb_float_mul(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1048 else if (RB_BIGNUM_TYPE_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) * rb_big2dbl(y)); } - else if (RB_TYPE_P(y, T_FLOAT)) { + else if (RB_FLOAT_TYPE_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) * RFLOAT_VALUE(y)); } else { @@ -1100,7 +1100,7 @@ rb_float_div(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1100 else if (RB_BIGNUM_TYPE_P(y)) { den = rb_big2dbl(y); } - else if (RB_TYPE_P(y, T_FLOAT)) { + else if (RB_FLOAT_TYPE_P(y)) { den = RFLOAT_VALUE(y); } else { @@ -1198,7 +1198,7 @@ flo_mod(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1198 else if (RB_BIGNUM_TYPE_P(y)) { fy = rb_big2dbl(y); } - else if (RB_TYPE_P(y, T_FLOAT)) { + else if (RB_FLOAT_TYPE_P(y)) { fy = RFLOAT_VALUE(y); } else { @@ -1238,7 +1238,7 @@ flo_divmod(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1238 else if (RB_BIGNUM_TYPE_P(y)) { fy = rb_big2dbl(y); } - else if (RB_TYPE_P(y, T_FLOAT)) { + else if (RB_FLOAT_TYPE_P(y)) { fy = RFLOAT_VALUE(y); } else { @@ -1275,7 +1275,7 @@ rb_float_pow(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1275 dx = RFLOAT_VALUE(x); dy = rb_big2dbl(y); } - else if (RB_TYPE_P(y, T_FLOAT)) { + else if (RB_FLOAT_TYPE_P(y)) { dx = RFLOAT_VALUE(x); dy = RFLOAT_VALUE(y); if (dx < 0 && dy != round(dy)) @@ -1355,7 +1355,7 @@ rb_float_equal(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1355 if (RB_INTEGER_TYPE_P(y)) { return rb_integer_float_eq(y, x); } - else if (RB_TYPE_P(y, T_FLOAT)) { + else if (RB_FLOAT_TYPE_P(y)) { b = RFLOAT_VALUE(y); #if MSC_VERSION_BEFORE(1300) if (isnan(b)) return Qfalse; @@ -1433,7 +1433,7 @@ flo_cmp(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1433 return LONG2FIX(-FIX2LONG(rel)); return rel; } - else if (RB_TYPE_P(y, T_FLOAT)) { + else if (RB_FLOAT_TYPE_P(y)) { b = RFLOAT_VALUE(y); } else { @@ -1479,7 +1479,7 @@ rb_float_gt(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1479 return RBOOL(-FIX2LONG(rel) > 0); return Qfalse; } - else if (RB_TYPE_P(y, T_FLOAT)) { + else if (RB_FLOAT_TYPE_P(y)) { b = RFLOAT_VALUE(y); #if MSC_VERSION_BEFORE(1300) if (isnan(b)) return Qfalse; @@ -1516,7 +1516,7 @@ flo_ge(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1516 return RBOOL(-FIX2LONG(rel) >= 0); return Qfalse; } - else if (RB_TYPE_P(y, T_FLOAT)) { + else if (RB_FLOAT_TYPE_P(y)) { b = RFLOAT_VALUE(y); #if MSC_VERSION_BEFORE(1300) if (isnan(b)) return Qfalse; @@ -1553,7 +1553,7 @@ flo_lt(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1553 return RBOOL(-FIX2LONG(rel) < 0); return Qfalse; } - else if (RB_TYPE_P(y, T_FLOAT)) { + else if (RB_FLOAT_TYPE_P(y)) { b = RFLOAT_VALUE(y); #if MSC_VERSION_BEFORE(1300) if (isnan(b)) return Qfalse; @@ -1590,7 +1590,7 @@ flo_le(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1590 return RBOOL(-FIX2LONG(rel) <= 0); return Qfalse; } - else if (RB_TYPE_P(y, T_FLOAT)) { + else if (RB_FLOAT_TYPE_P(y)) { b = RFLOAT_VALUE(y); #if MSC_VERSION_BEFORE(1300) if (isnan(b)) return Qfalse; @@ -1621,7 +1621,7 @@ flo_le(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1621 MJIT_FUNC_EXPORTED VALUE rb_float_eql(VALUE x, VALUE y) { - if (RB_TYPE_P(y, T_FLOAT)) { + if (RB_FLOAT_TYPE_P(y)) { double a = RFLOAT_VALUE(x); double b = RFLOAT_VALUE(y); #if MSC_VERSION_BEFORE(1300) @@ -2050,7 +2050,7 @@ rb_int_round(VALUE num, int ndigits, enum ruby_num_rounding_mode mode) https://github.com/ruby/ruby/blob/trunk/numeric.c#L2050 if (neg) x = -x; return LONG2NUM(x); } - if (RB_TYPE_P(f, T_FLOAT)) { + if (RB_FLOAT_TYPE_P(f)) { /* then int_pow overflow */ return INT2FIX(0); } @@ -2081,7 +2081,7 @@ rb_int_floor(VALUE num, int ndigits) https://github.com/ruby/ruby/blob/trunk/numeric.c#L2081 if (neg) x = -x; return LONG2NUM(x); } - if (RB_TYPE_P(f, T_FLOAT)) { + if (RB_FLOAT_TYPE_P(f)) { /* then int_pow overflow */ return INT2FIX(0); } @@ -2105,7 +2105,7 @@ rb_int_ceil(VALUE num, int ndigits) https://github.com/ruby/ruby/blob/trunk/numeric.c#L2105 if (neg) x = -x; return LONG2NUM(x); } - if (RB_TYPE_P(f, T_FLOAT)) { + if (RB_FLOAT_TYPE_P(f)) { /* then int_pow overflow */ return INT2FIX(0); } @@ -2129,7 +2129,7 @@ rb_int_truncate(VALUE num, int ndigits) https://github.com/ruby/ruby/blob/trunk/numeric.c#L2129 if (neg) x = -x; return LONG2NUM(x); } - if (RB_TYPE_P(f, T_FLOAT)) { + if (RB_FLOAT_TYPE_P(f)) { /* then int_pow overflow */ return INT2FIX(0); } @@ -2447,7 +2447,7 @@ ruby_float_step_size(double beg, double end, double unit, int excl) https://github.com/ruby/ruby/blob/trunk/numeric.c#L2447 int ruby_float_step(VALUE from, VALUE to, VALUE step, int excl, int allow_endless) { - if (RB_TYPE_P(from, T_FLOAT) || RB_TYPE_P(to, T_FLOAT) || RB_TYPE_P(step, T_FLOAT)) { + if (RB_FLOAT_TYPE_P(from) || RB_FLOAT_TYPE_P(to) || RB_FLOAT_TYPE_P(step)) { double unit = NUM2DBL(step); double beg = NUM2DBL(from); double end = (allow_endless && NIL_P(to)) ? (unit < 0 ? -1 : 1)*HUGE_VAL : NUM2DBL(to); @@ -2498,7 +2498,7 @@ ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl) https://github.com/ruby/ruby/blob/trunk/numeric.c#L2498 } return ULONG2NUM(delta / diff + 1UL); } - else if (RB_TYPE_P(from, T_FLOAT) || RB_TYPE_P(to, T_FLOAT) || RB_TYPE_P(step, T_FLOAT)) { + else if (RB_FLOAT_TYPE_P(from) || RB_FLOAT_TYPE_P(to) || RB_FLOAT_TYPE_P(step)) { double n = ruby_float_step_size(NUM2DBL(from), NUM2DBL(to), NUM2DBL(step), excl); if (isinf(n)) return DBL2NUM(n); @@ -2703,7 +2703,7 @@ num_step(int argc, VALUE *argv, VALUE from) https://github.com/ruby/ruby/blob/trunk/numeric.c#L2703 if (rb_equal(step, INT2FIX(0))) { inf = 1; } - else if (RB_TYPE_P(to, T_FLOAT)) { + else if (RB_FLOAT_TYPE_P(to)) { double f = RFLOAT_VALUE(to); inf = isinf(f) && (signbit(f) ? desc : !desc); } @@ -2782,7 +2782,7 @@ rb_num2long(VALUE val) https://githu (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/