Predefine some IDs
This commit is contained in:
parent
0bd1cd677f
commit
4ea5c5610a
6
bignum.c
6
bignum.c
@ -6082,7 +6082,7 @@ rb_big_div(VALUE x, VALUE y)
|
|||||||
VALUE
|
VALUE
|
||||||
rb_big_idiv(VALUE x, VALUE y)
|
rb_big_idiv(VALUE x, VALUE y)
|
||||||
{
|
{
|
||||||
return rb_big_divide(x, y, rb_intern("div"));
|
return rb_big_divide(x, y, idDiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
@ -6126,7 +6126,7 @@ rb_big_divmod(VALUE x, VALUE y)
|
|||||||
y = rb_int2big(FIX2LONG(y));
|
y = rb_int2big(FIX2LONG(y));
|
||||||
}
|
}
|
||||||
else if (!RB_BIGNUM_TYPE_P(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);
|
bigdivmod(x, y, &div, &mod);
|
||||||
|
|
||||||
@ -6214,7 +6214,7 @@ rb_big_fdiv_double(VALUE x, VALUE y)
|
|||||||
return big_fdiv_float(x, y);
|
return big_fdiv_float(x, y);
|
||||||
}
|
}
|
||||||
else {
|
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));
|
v = rb_flo_div_flo(DBL2NUM(dx), DBL2NUM(dy));
|
||||||
return NUM2DBL(v);
|
return NUM2DBL(v);
|
||||||
|
@ -33,7 +33,7 @@ extern int signbit(double);
|
|||||||
VALUE rb_cComplex;
|
VALUE rb_cComplex;
|
||||||
|
|
||||||
static ID id_abs, id_arg,
|
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_real_p, id_i_real, id_i_imag,
|
||||||
id_finite_p, id_infinite_p, id_rationalize,
|
id_finite_p, id_infinite_p, id_rationalize,
|
||||||
id_PI;
|
id_PI;
|
||||||
@ -42,6 +42,8 @@ static ID id_abs, id_arg,
|
|||||||
#define id_negate idUMinus
|
#define id_negate idUMinus
|
||||||
#define id_expt idPow
|
#define id_expt idPow
|
||||||
#define id_to_f idTo_f
|
#define id_to_f idTo_f
|
||||||
|
#define id_quo idQuo
|
||||||
|
#define id_fdiv idFdiv
|
||||||
|
|
||||||
#define f_boolcast(x) ((x) ? Qtrue : Qfalse)
|
#define f_boolcast(x) ((x) ? Qtrue : Qfalse)
|
||||||
|
|
||||||
@ -2278,9 +2280,7 @@ Init_Complex(void)
|
|||||||
id_abs = rb_intern("abs");
|
id_abs = rb_intern("abs");
|
||||||
id_arg = rb_intern("arg");
|
id_arg = rb_intern("arg");
|
||||||
id_denominator = rb_intern("denominator");
|
id_denominator = rb_intern("denominator");
|
||||||
id_fdiv = rb_intern("fdiv");
|
|
||||||
id_numerator = rb_intern("numerator");
|
id_numerator = rb_intern("numerator");
|
||||||
id_quo = rb_intern("quo");
|
|
||||||
id_real_p = rb_intern("real?");
|
id_real_p = rb_intern("real?");
|
||||||
id_i_real = rb_intern("@real");
|
id_i_real = rb_intern("@real");
|
||||||
id_i_imag = rb_intern("@image"); /* @image, not @imag */
|
id_i_imag = rb_intern("@image"); /* @image, not @imag */
|
||||||
|
@ -49,6 +49,11 @@ firstline, predefined = __LINE__+1, %[\
|
|||||||
not NOT
|
not NOT
|
||||||
and AND
|
and AND
|
||||||
or OR
|
or OR
|
||||||
|
div
|
||||||
|
divmod
|
||||||
|
fdiv
|
||||||
|
quo
|
||||||
|
name
|
||||||
|
|
||||||
_ UScore
|
_ UScore
|
||||||
"/*NULL*/" NULL
|
"/*NULL*/" NULL
|
||||||
|
3
enum.c
3
enum.c
@ -21,8 +21,8 @@
|
|||||||
VALUE rb_mEnumerable;
|
VALUE rb_mEnumerable;
|
||||||
|
|
||||||
static ID id_next;
|
static ID id_next;
|
||||||
static ID id_div;
|
|
||||||
|
|
||||||
|
#define id_div idDiv
|
||||||
#define id_each idEach
|
#define id_each idEach
|
||||||
#define id_eqq idEqq
|
#define id_eqq idEqq
|
||||||
#define id_cmp idCmp
|
#define id_cmp idCmp
|
||||||
@ -4201,5 +4201,4 @@ Init_Enumerable(void)
|
|||||||
rb_define_method(rb_mEnumerable, "uniq", enum_uniq, 0);
|
rb_define_method(rb_mEnumerable, "uniq", enum_uniq, 0);
|
||||||
|
|
||||||
id_next = rb_intern("next");
|
id_next = rb_intern("next");
|
||||||
id_div = rb_intern("div");
|
|
||||||
}
|
}
|
||||||
|
4
error.c
4
error.c
@ -884,12 +884,13 @@ static VALUE rb_eNOERROR;
|
|||||||
ID ruby_static_id_cause;
|
ID ruby_static_id_cause;
|
||||||
#define id_cause ruby_static_id_cause
|
#define id_cause ruby_static_id_cause
|
||||||
static ID id_message, id_backtrace;
|
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_receiver, id_recv, id_iseq, id_local_variables;
|
||||||
static ID id_private_call_p, id_top, id_bottom;
|
static ID id_private_call_p, id_top, id_bottom;
|
||||||
#define id_bt idBt
|
#define id_bt idBt
|
||||||
#define id_bt_locations idBt_locations
|
#define id_bt_locations idBt_locations
|
||||||
#define id_mesg idMesg
|
#define id_mesg idMesg
|
||||||
|
#define id_name idName
|
||||||
|
|
||||||
#undef rb_exc_new_cstr
|
#undef rb_exc_new_cstr
|
||||||
|
|
||||||
@ -2538,7 +2539,6 @@ Init_Exception(void)
|
|||||||
id_cause = rb_intern_const("cause");
|
id_cause = rb_intern_const("cause");
|
||||||
id_message = rb_intern_const("message");
|
id_message = rb_intern_const("message");
|
||||||
id_backtrace = rb_intern_const("backtrace");
|
id_backtrace = rb_intern_const("backtrace");
|
||||||
id_name = rb_intern_const("name");
|
|
||||||
id_key = rb_intern_const("key");
|
id_key = rb_intern_const("key");
|
||||||
id_args = rb_intern_const("args");
|
id_args = rb_intern_const("args");
|
||||||
id_receiver = rb_intern_const("receiver");
|
id_receiver = rb_intern_const("receiver");
|
||||||
|
13
numeric.c
13
numeric.c
@ -171,7 +171,9 @@ static VALUE flo_to_i(VALUE num);
|
|||||||
static int float_round_overflow(int ndigits, int binexp);
|
static int float_round_overflow(int ndigits, int binexp);
|
||||||
static int float_round_underflow(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_to_i idTo_i
|
||||||
#define id_eq idEq
|
#define id_eq idEq
|
||||||
#define id_cmp idCmp
|
#define id_cmp idCmp
|
||||||
@ -3717,7 +3719,7 @@ fix_fdiv_double(VALUE x, VALUE y)
|
|||||||
return double_div_double(FIX2LONG(x), RFLOAT_VALUE(y));
|
return double_div_double(FIX2LONG(x), RFLOAT_VALUE(y));
|
||||||
}
|
}
|
||||||
else {
|
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)
|
|||||||
_set_Creg(0, 0);
|
_set_Creg(0, 0);
|
||||||
#endif
|
#endif
|
||||||
id_coerce = rb_intern("coerce");
|
id_coerce = rb_intern("coerce");
|
||||||
id_div = rb_intern("div");
|
id_to = rb_intern("to");
|
||||||
id_divmod = rb_intern("divmod");
|
id_by = rb_intern("by");
|
||||||
|
|
||||||
rb_eZeroDivError = rb_define_class("ZeroDivisionError", rb_eStandardError);
|
rb_eZeroDivError = rb_define_class("ZeroDivisionError", rb_eStandardError);
|
||||||
rb_eFloatDomainError = rb_define_class("FloatDomainError", rb_eRangeError);
|
rb_eFloatDomainError = rb_define_class("FloatDomainError", rb_eRangeError);
|
||||||
@ -5821,9 +5823,6 @@ Init_Numeric(void)
|
|||||||
rb_define_method(rb_cFloat, "prev_float", flo_prev_float, 0);
|
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, "positive?", flo_positive_p, 0);
|
||||||
rb_define_method(rb_cFloat, "negative?", flo_negative_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
|
#undef rb_float_value
|
||||||
|
@ -33,8 +33,10 @@
|
|||||||
|
|
||||||
VALUE rb_cRational;
|
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;
|
id_i_num, id_i_den;
|
||||||
|
|
||||||
|
#define id_idiv idDiv
|
||||||
#define id_to_i idTo_i
|
#define id_to_i idTo_i
|
||||||
|
|
||||||
#define f_boolcast(x) ((x) ? Qtrue : Qfalse)
|
#define f_boolcast(x) ((x) ? Qtrue : Qfalse)
|
||||||
@ -1601,7 +1603,7 @@ f_ceil(VALUE x)
|
|||||||
return rb_funcall(x, id_ceil, 0);
|
return rb_funcall(x, id_ceil, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define id_quo rb_intern("quo")
|
#define id_quo idQuo
|
||||||
static VALUE
|
static VALUE
|
||||||
f_quo(VALUE x, VALUE y)
|
f_quo(VALUE x, VALUE y)
|
||||||
{
|
{
|
||||||
@ -2013,7 +2015,7 @@ VALUE
|
|||||||
rb_numeric_quo(VALUE x, VALUE y)
|
rb_numeric_quo(VALUE x, VALUE y)
|
||||||
{
|
{
|
||||||
if (RB_FLOAT_TYPE_P(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) {
|
if (canonicalization) {
|
||||||
@ -2711,7 +2713,6 @@ Init_Rational(void)
|
|||||||
#define rb_intern(str) rb_intern_const(str)
|
#define rb_intern(str) rb_intern_const(str)
|
||||||
|
|
||||||
id_abs = rb_intern("abs");
|
id_abs = rb_intern("abs");
|
||||||
id_idiv = rb_intern("div");
|
|
||||||
id_integer_p = rb_intern("integer?");
|
id_integer_p = rb_intern("integer?");
|
||||||
id_i_num = rb_intern("@numerator");
|
id_i_num = rb_intern("@numerator");
|
||||||
id_i_den = rb_intern("@denominator");
|
id_i_den = rb_intern("@denominator");
|
||||||
|
15
time.c
15
time.c
@ -35,11 +35,14 @@
|
|||||||
#include "timev.h"
|
#include "timev.h"
|
||||||
#include "id.h"
|
#include "id.h"
|
||||||
|
|
||||||
static ID id_divmod, id_submicro, id_nano_num, id_nano_den, id_offset, id_zone;
|
static ID id_submicro, id_nano_num, id_nano_den, id_offset, id_zone;
|
||||||
static ID id_quo, id_div;
|
|
||||||
static ID id_nanosecond, id_microsecond, id_millisecond, id_nsec, id_usec;
|
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_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
|
#define UTC_ZONE Qundef
|
||||||
|
|
||||||
#ifndef TM_IS_TIME
|
#ifndef TM_IS_TIME
|
||||||
@ -5600,7 +5603,7 @@ rb_time_zone_abbreviation(VALUE zone, VALUE time)
|
|||||||
if (abbr != Qundef) {
|
if (abbr != Qundef) {
|
||||||
goto found;
|
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:
|
found:
|
||||||
return rb_obj_as_string(abbr);
|
return rb_obj_as_string(abbr);
|
||||||
}
|
}
|
||||||
@ -5740,9 +5743,6 @@ Init_Time(void)
|
|||||||
#undef rb_intern
|
#undef rb_intern
|
||||||
#define rb_intern(str) rb_intern_const(str)
|
#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_submicro = rb_intern("submicro");
|
||||||
id_nano_num = rb_intern("nano_num");
|
id_nano_num = rb_intern("nano_num");
|
||||||
id_nano_den = rb_intern("nano_den");
|
id_nano_den = rb_intern("nano_den");
|
||||||
@ -5762,7 +5762,6 @@ Init_Time(void)
|
|||||||
id_min = rb_intern("min");
|
id_min = rb_intern("min");
|
||||||
id_sec = rb_intern("sec");
|
id_sec = rb_intern("sec");
|
||||||
id_isdst = rb_intern("isdst");
|
id_isdst = rb_intern("isdst");
|
||||||
id_name = rb_intern("name");
|
|
||||||
id_find_timezone = rb_intern("find_timezone");
|
id_find_timezone = rb_intern("find_timezone");
|
||||||
|
|
||||||
rb_cTime = rb_define_class("Time", rb_cObject);
|
rb_cTime = rb_define_class("Time", rb_cObject);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user