ruby-changes:56776
From: Nobuyoshi <ko1@a...>
Date: Sat, 3 Aug 2019 10:30:34 +0900 (JST)
Subject: [ruby-changes:56776] Nobuyoshi Nakada: 4ea5c5610a (master): Predefine some IDs
https://git.ruby-lang.org/ruby.git/commit/?id=4ea5c5610a From 4ea5c5610aeadecf78fdd2b7d6faad8574953620 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sat, 3 Aug 2019 08:37:08 +0900 Subject: Predefine some IDs diff --git a/bignum.c b/bignum.c index 212d19a..2818b05 100644 --- a/bignum.c +++ b/bignum.c @@ -6082,7 +6082,7 @@ rb_big_div(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/bignum.c#L6082 VALUE rb_big_idiv(VALUE x, VALUE y) { - return rb_big_divide(x, y, rb_intern("div")); + return rb_big_divide(x, y, idDiv); } VALUE @@ -6126,7 +6126,7 @@ rb_big_divmod(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/bignum.c#L6126 y = rb_int2big(FIX2LONG(y)); } else if (!RB_BIGNUM_TYPE_P(y)) { - return rb_num_coerce_bin(x, y, rb_intern("divmod")); + return rb_num_coerce_bin(x, y, idDivmod); } bigdivmod(x, y, &div, &mod); @@ -6214,7 +6214,7 @@ rb_big_fdiv_double(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/bignum.c#L6214 return big_fdiv_float(x, y); } else { - return NUM2DBL(rb_num_coerce_bin(x, y, rb_intern("fdiv"))); + return NUM2DBL(rb_num_coerce_bin(x, y, idFdiv)); } v = rb_flo_div_flo(DBL2NUM(dx), DBL2NUM(dy)); return NUM2DBL(v); diff --git a/complex.c b/complex.c index fa00036..4c51d1a 100644 --- a/complex.c +++ b/complex.c @@ -33,7 +33,7 @@ extern int signbit(double); https://github.com/ruby/ruby/blob/trunk/complex.c#L33 VALUE rb_cComplex; static ID id_abs, id_arg, - id_denominator, id_fdiv, id_numerator, id_quo, + id_denominator, id_numerator, id_real_p, id_i_real, id_i_imag, id_finite_p, id_infinite_p, id_rationalize, id_PI; @@ -42,6 +42,8 @@ static ID id_abs, id_arg, https://github.com/ruby/ruby/blob/trunk/complex.c#L42 #define id_negate idUMinus #define id_expt idPow #define id_to_f idTo_f +#define id_quo idQuo +#define id_fdiv idFdiv #define f_boolcast(x) ((x) ? Qtrue : Qfalse) @@ -2278,9 +2280,7 @@ Init_Complex(void) https://github.com/ruby/ruby/blob/trunk/complex.c#L2280 id_abs = rb_intern("abs"); id_arg = rb_intern("arg"); id_denominator = rb_intern("denominator"); - id_fdiv = rb_intern("fdiv"); id_numerator = rb_intern("numerator"); - id_quo = rb_intern("quo"); id_real_p = rb_intern("real?"); id_i_real = rb_intern("@real"); id_i_imag = rb_intern("@image"); /* @image, not @imag */ diff --git a/defs/id.def b/defs/id.def index 25677ff..1296b12 100644 --- a/defs/id.def +++ b/defs/id.def @@ -49,6 +49,11 @@ firstline, predefined = __LINE__+1, %[\ https://github.com/ruby/ruby/blob/trunk/defs/id.def#L49 not NOT and AND or OR + div + divmod + fdiv + quo + name _ UScore "/*NULL*/" NULL diff --git a/enum.c b/enum.c index c06e336..f97a2d1 100644 --- a/enum.c +++ b/enum.c @@ -21,8 +21,8 @@ https://github.com/ruby/ruby/blob/trunk/enum.c#L21 VALUE rb_mEnumerable; static ID id_next; -static ID id_div; +#define id_div idDiv #define id_each idEach #define id_eqq idEqq #define id_cmp idCmp @@ -4201,5 +4201,4 @@ Init_Enumerable(void) https://github.com/ruby/ruby/blob/trunk/enum.c#L4201 rb_define_method(rb_mEnumerable, "uniq", enum_uniq, 0); id_next = rb_intern("next"); - id_div = rb_intern("div"); } diff --git a/error.c b/error.c index 00ee6df..8834100 100644 --- a/error.c +++ b/error.c @@ -884,12 +884,13 @@ static VALUE rb_eNOERROR; https://github.com/ruby/ruby/blob/trunk/error.c#L884 ID ruby_static_id_cause; #define id_cause ruby_static_id_cause static ID id_message, id_backtrace; -static ID id_name, id_key, id_args, id_Errno, id_errno, id_i_path; +static ID id_key, id_args, id_Errno, id_errno, id_i_path; static ID id_receiver, id_recv, id_iseq, id_local_variables; static ID id_private_call_p, id_top, id_bottom; #define id_bt idBt #define id_bt_locations idBt_locations #define id_mesg idMesg +#define id_name idName #undef rb_exc_new_cstr @@ -2538,7 +2539,6 @@ Init_Exception(void) https://github.com/ruby/ruby/blob/trunk/error.c#L2539 id_cause = rb_intern_const("cause"); id_message = rb_intern_const("message"); id_backtrace = rb_intern_const("backtrace"); - id_name = rb_intern_const("name"); id_key = rb_intern_const("key"); id_args = rb_intern_const("args"); id_receiver = rb_intern_const("receiver"); diff --git a/numeric.c b/numeric.c index 7ce6590..2f5da6f 100644 --- a/numeric.c +++ b/numeric.c @@ -171,7 +171,9 @@ static VALUE flo_to_i(VALUE num); https://github.com/ruby/ruby/blob/trunk/numeric.c#L171 static int float_round_overflow(int ndigits, int binexp); static int float_round_underflow(int ndigits, int binexp); -static ID id_coerce, id_div, id_divmod; +static ID id_coerce; +#define id_div idDiv +#define id_divmod idDivmod #define id_to_i idTo_i #define id_eq idEq #define id_cmp idCmp @@ -3717,7 +3719,7 @@ fix_fdiv_double(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L3719 return double_div_double(FIX2LONG(x), RFLOAT_VALUE(y)); } else { - return NUM2DBL(rb_num_coerce_bin(x, y, rb_intern("fdiv"))); + return NUM2DBL(rb_num_coerce_bin(x, y, idFdiv)); } } @@ -5561,8 +5563,8 @@ Init_Numeric(void) https://github.com/ruby/ruby/blob/trunk/numeric.c#L5563 _set_Creg(0, 0); #endif id_coerce = rb_intern("coerce"); - id_div = rb_intern("div"); - id_divmod = rb_intern("divmod"); + id_to = rb_intern("to"); + id_by = rb_intern("by"); rb_eZeroDivError = rb_define_class("ZeroDivisionError", rb_eStandardError); rb_eFloatDomainError = rb_define_class("FloatDomainError", rb_eRangeError); @@ -5821,9 +5823,6 @@ Init_Numeric(void) https://github.com/ruby/ruby/blob/trunk/numeric.c#L5823 rb_define_method(rb_cFloat, "prev_float", flo_prev_float, 0); rb_define_method(rb_cFloat, "positive?", flo_positive_p, 0); rb_define_method(rb_cFloat, "negative?", flo_negative_p, 0); - - id_to = rb_intern("to"); - id_by = rb_intern("by"); } #undef rb_float_value diff --git a/rational.c b/rational.c index ed7e356..d032cbd 100644 --- a/rational.c +++ b/rational.c @@ -33,8 +33,10 @@ https://github.com/ruby/ruby/blob/trunk/rational.c#L33 VALUE rb_cRational; -static ID id_abs, id_idiv, id_integer_p, +static ID id_abs, id_integer_p, id_i_num, id_i_den; + +#define id_idiv idDiv #define id_to_i idTo_i #define f_boolcast(x) ((x) ? Qtrue : Qfalse) @@ -1601,7 +1603,7 @@ f_ceil(VALUE x) https://github.com/ruby/ruby/blob/trunk/rational.c#L1603 return rb_funcall(x, id_ceil, 0); } -#define id_quo rb_intern("quo") +#define id_quo idQuo static VALUE f_quo(VALUE x, VALUE y) { @@ -2013,7 +2015,7 @@ VALUE https://github.com/ruby/ruby/blob/trunk/rational.c#L2015 rb_numeric_quo(VALUE x, VALUE y) { if (RB_FLOAT_TYPE_P(y)) { - return rb_funcall(x, rb_intern("fdiv"), 1, y); + return rb_funcallv(x, idFdiv, 1, &y); } if (canonicalization) { @@ -2711,7 +2713,6 @@ Init_Rational(void) https://github.com/ruby/ruby/blob/trunk/rational.c#L2713 #define rb_intern(str) rb_intern_const(str) id_abs = rb_intern("abs"); - id_idiv = rb_intern("div"); id_integer_p = rb_intern("integer?"); id_i_num = rb_intern("@numerator"); id_i_den = rb_intern("@denominator"); diff --git a/time.c b/time.c index 7f39799..91e7d9d 100644 --- a/time.c +++ b/time.c @@ -35,11 +35,14 @@ https://github.com/ruby/ruby/blob/trunk/time.c#L35 #include "timev.h" #include "id.h" -static ID id_divmod, id_submicro, id_nano_num, id_nano_den, id_offset, id_zone; -static ID id_quo, id_div; +static ID id_submicro, id_nano_num, id_nano_den, id_offset, id_zone; static ID id_nanosecond, id_microsecond, id_millisecond, id_nsec, id_usec; static ID id_local_to_utc, id_utc_to_local, id_find_timezone; -static ID id_year, id_mon, id_mday, id_hour, id_min, id_sec, id_isdst, id_name; +static ID id_year, id_mon, id_mday, id_hour, id_min, id_sec, id_isdst; +#define id_quo idQuo +#define id_div idDiv +#define id_divmod idDivmod +#define id_name idName #define UTC_ZONE Qundef #ifndef TM_IS_TIME @@ -5600,7 +5603,7 @@ rb_time_zone_abbreviation(VALUE zone, VALUE time) https://github.com/ruby/ruby/blob/trunk/time.c#L5603 if (abbr != Qundef) { goto found; } - abbr = rb_check_funcall_default(zone, rb_intern("name"), 0, 0, Qnil); + abbr = rb_check_funcall_default(zone, idName, 0, 0, Qnil); found: return rb_obj_as_string(abbr); } @@ -5740,9 +5743,6 @@ Init_Time(void) https://github.com/ruby/ruby/blob/trunk/time.c#L5743 #undef rb_intern #define rb_intern(str) rb_intern_const(str) - id_quo = rb_intern("quo"); - id_div = rb_intern("div"); - id_divmod = rb_intern("divmod"); id_submicro = rb_intern("submicro"); id_nano_num = rb_intern("nano_num"); id_nano_den = rb_intern("nano_den"); @@ -5762,7 +5762,6 @@ Init_Time(void) https://github.com/ruby/ruby/blob/trunk/time.c#L5762 id_min = rb_intern("min"); id_sec = rb_intern("sec"); id_isdst = rb_intern("isdst"); - id_name = rb_intern("name"); id_find_timezone = rb_intern("find_timezone"); rb_cTime = rb_define_class("Time", rb_cObject); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/