ruby-changes:67951
From: S-H-GAMELINKS <ko1@a...>
Date: Sun, 12 Sep 2021 11:16:29 +0900 (JST)
Subject: [ruby-changes:67951] af5826a25e (master): Replace RB_TYPE_P macro to FIXNUM_P and RB_INTEGER_TYPE_P macro
https://git.ruby-lang.org/ruby.git/commit/?id=af5826a25e From af5826a25e24ba7179038f99362aa918d48bd8be Mon Sep 17 00:00:00 2001 From: S-H-GAMELINKS <gamelinks007@g...> Date: Sat, 11 Sep 2021 13:45:22 +0900 Subject: Replace RB_TYPE_P macro to FIXNUM_P and RB_INTEGER_TYPE_P macro --- load.c | 2 +- numeric.c | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/load.c b/load.c index eaa2a59..5fb805d 100644 --- a/load.c +++ b/load.c @@ -208,7 +208,7 @@ features_index_add_single(const char* str, size_t len, VALUE offset, bool rb) https://github.com/ruby/ruby/blob/trunk/load.c#L208 NIL_P(this_feature_index = (VALUE)data)) { st_insert(features_index, short_feature_key, (st_data_t)offset); } - else if (RB_TYPE_P(this_feature_index, T_FIXNUM)) { + else if (FIXNUM_P(this_feature_index)) { VALUE loaded_features = get_loaded_features(); VALUE this_feature_path = RARRAY_AREF(loaded_features, FIX2LONG(this_feature_index)); VALUE feature_indexes[2]; diff --git a/numeric.c b/numeric.c index f925b93..7616c2b 100644 --- a/numeric.c +++ b/numeric.c @@ -994,7 +994,7 @@ rb_float_uminus(VALUE flt) https://github.com/ruby/ruby/blob/trunk/numeric.c#L994 VALUE rb_float_plus(VALUE x, VALUE y) { - if (RB_TYPE_P(y, T_FIXNUM)) { + if (FIXNUM_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) + (double)FIX2LONG(y)); } else if (RB_BIGNUM_TYPE_P(y)) { @@ -1018,7 +1018,7 @@ rb_float_plus(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1018 VALUE rb_float_minus(VALUE x, VALUE y) { - if (RB_TYPE_P(y, T_FIXNUM)) { + if (FIXNUM_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) - (double)FIX2LONG(y)); } else if (RB_BIGNUM_TYPE_P(y)) { @@ -1042,7 +1042,7 @@ rb_float_minus(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1042 VALUE rb_float_mul(VALUE x, VALUE y) { - if (RB_TYPE_P(y, T_FIXNUM)) { + if (FIXNUM_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) * (double)FIX2LONG(y)); } else if (RB_BIGNUM_TYPE_P(y)) { @@ -1094,7 +1094,7 @@ rb_float_div(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1094 double den; double ret; - if (RB_TYPE_P(y, T_FIXNUM)) { + if (FIXNUM_P(y)) { den = FIX2LONG(y); } else if (RB_BIGNUM_TYPE_P(y)) { @@ -1192,7 +1192,7 @@ flo_mod(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1192 { double fy; - if (RB_TYPE_P(y, T_FIXNUM)) { + if (FIXNUM_P(y)) { fy = (double)FIX2LONG(y); } else if (RB_BIGNUM_TYPE_P(y)) { @@ -1232,7 +1232,7 @@ flo_divmod(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1232 double fy, div, mod; volatile VALUE a, b; - if (RB_TYPE_P(y, T_FIXNUM)) { + if (FIXNUM_P(y)) { fy = (double)FIX2LONG(y); } else if (RB_BIGNUM_TYPE_P(y)) { @@ -1267,7 +1267,7 @@ rb_float_pow(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1267 dx = RFLOAT_VALUE(x); return DBL2NUM(dx * dx); } - else if (RB_TYPE_P(y, T_FIXNUM)) { + else if (FIXNUM_P(y)) { dx = RFLOAT_VALUE(x); dy = (double)FIX2LONG(y); } @@ -1352,7 +1352,7 @@ rb_float_equal(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1352 { volatile double a, b; - if (RB_TYPE_P(y, T_FIXNUM) || RB_BIGNUM_TYPE_P(y)) { + if (RB_INTEGER_TYPE_P(y)) { return rb_integer_float_eq(y, x); } else if (RB_TYPE_P(y, T_FLOAT)) { @@ -1427,7 +1427,7 @@ flo_cmp(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1427 a = RFLOAT_VALUE(x); if (isnan(a)) return Qnil; - if (RB_TYPE_P(y, T_FIXNUM) || RB_BIGNUM_TYPE_P(y)) { + if (RB_INTEGER_TYPE_P(y)) { VALUE rel = rb_integer_float_cmp(y, x); if (FIXNUM_P(rel)) return LONG2FIX(-FIX2LONG(rel)); @@ -1473,7 +1473,7 @@ rb_float_gt(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1473 double a, b; a = RFLOAT_VALUE(x); - if (RB_TYPE_P(y, T_FIXNUM) || RB_BIGNUM_TYPE_P(y)) { + if (RB_INTEGER_TYPE_P(y)) { VALUE rel = rb_integer_float_cmp(y, x); if (FIXNUM_P(rel)) return RBOOL(-FIX2LONG(rel) > 0); @@ -1547,7 +1547,7 @@ flo_lt(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1547 double a, b; a = RFLOAT_VALUE(x); - if (RB_TYPE_P(y, T_FIXNUM) || RB_BIGNUM_TYPE_P(y)) { + if (RB_INTEGER_TYPE_P(y)) { VALUE rel = rb_integer_float_cmp(y, x); if (FIXNUM_P(rel)) return RBOOL(-FIX2LONG(rel) < 0); @@ -1584,7 +1584,7 @@ flo_le(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1584 double a, b; a = RFLOAT_VALUE(x); - if (RB_TYPE_P(y, T_FIXNUM) || RB_BIGNUM_TYPE_P(y)) { + if (RB_INTEGER_TYPE_P(y)) { VALUE rel = rb_integer_float_cmp(y, x); if (FIXNUM_P(rel)) return RBOOL(-FIX2LONG(rel) <= 0); @@ -3082,7 +3082,7 @@ rb_num2ull(VALUE val) https://github.com/ruby/ruby/blob/trunk/numeric.c#L3082 if (NIL_P(val)) { rb_raise(rb_eTypeError, "no implicit conversion from nil"); } - else if (RB_TYPE_P(val, T_FIXNUM)) { + else if (FIXNUM_P(val)) { return (LONG_LONG)FIX2LONG(val); /* this is FIX2LONG, intended */ } else if (RB_TYPE_P(val, T_FLOAT)) { -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/