ruby-changes:49890
From: kazu <ko1@a...>
Date: Mon, 22 Jan 2018 22:09:44 +0900 (JST)
Subject: [ruby-changes:49890] kazu:r62008 (trunk): use predefined IDs
kazu 2018-01-22 22:09:37 +0900 (Mon, 22 Jan 2018) New Revision: 62008 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62008 Log: use predefined IDs Modified files: trunk/complex.c trunk/dir.c trunk/io.c trunk/proc.c trunk/rational.c trunk/variable.c trunk/vm_eval.c Index: proc.c =================================================================== --- proc.c (revision 62007) +++ proc.c (revision 62008) @@ -3082,7 +3082,7 @@ Init_Proc(void) https://github.com/ruby/ruby/blob/trunk/proc.c#L3082 rb_undef_alloc_func(rb_cProc); rb_define_singleton_method(rb_cProc, "new", rb_proc_s_new, -1); - rb_add_method(rb_cProc, rb_intern("call"), VM_METHOD_TYPE_OPTIMIZED, + rb_add_method(rb_cProc, idCall, VM_METHOD_TYPE_OPTIMIZED, (void *)OPTIMIZED_METHOD_TYPE_CALL, METHOD_VISI_PUBLIC); rb_add_method(rb_cProc, rb_intern("[]"), VM_METHOD_TYPE_OPTIMIZED, (void *)OPTIMIZED_METHOD_TYPE_CALL, METHOD_VISI_PUBLIC); Index: complex.c =================================================================== --- complex.c (revision 62007) +++ complex.c (revision 62008) @@ -12,6 +12,7 @@ https://github.com/ruby/ruby/blob/trunk/complex.c#L12 #endif #include <math.h> #include "internal.h" +#include "id.h" #define NDEBUG #include "ruby_assert.h" @@ -33,10 +34,12 @@ static VALUE nucomp_arg(VALUE self); https://github.com/ruby/ruby/blob/trunk/complex.c#L34 static ID id_abs, id_arg, id_denominator, id_expt, id_fdiv, id_negate, id_numerator, id_quo, - id_real_p, id_to_f, id_to_i, id_to_r, + id_real_p, id_to_f, id_i_real, id_i_imag, id_finite_p, id_infinite_p, id_rationalize, id_PI; +#define id_to_i idTo_i +#define id_to_r idTo_r #define f_boolcast(x) ((x) ? Qtrue : Qfalse) @@ -2204,8 +2207,6 @@ Init_Complex(void) https://github.com/ruby/ruby/blob/trunk/complex.c#L2207 id_quo = rb_intern("quo"); id_real_p = rb_intern("real?"); id_to_f = rb_intern("to_f"); - id_to_i = rb_intern("to_i"); - id_to_r = rb_intern("to_r"); id_i_real = rb_intern("@real"); id_i_imag = rb_intern("@image"); /* @image, not @imag */ id_finite_p = rb_intern("finite?"); Index: rational.c =================================================================== --- rational.c (revision 62007) +++ rational.c (revision 62008) @@ -33,8 +33,9 @@ https://github.com/ruby/ruby/blob/trunk/rational.c#L33 VALUE rb_cRational; -static ID id_abs, id_idiv, id_integer_p, id_to_i, +static ID id_abs, id_idiv, id_integer_p, id_i_num, id_i_den; +#define id_to_i idTo_i #define f_boolcast(x) ((x) ? Qtrue : Qfalse) #define f_inspect rb_inspect @@ -2003,7 +2004,7 @@ rb_rational_den(VALUE rat) https://github.com/ruby/ruby/blob/trunk/rational.c#L2004 #define id_denominator rb_intern("denominator") #define f_denominator(x) rb_funcall((x), id_denominator, 0) -#define id_to_r rb_intern("to_r") +#define id_to_r idTo_r #define f_to_r(x) rb_funcall((x), id_to_r, 0) /* @@ -2684,7 +2685,6 @@ Init_Rational(void) https://github.com/ruby/ruby/blob/trunk/rational.c#L2685 id_abs = rb_intern("abs"); id_idiv = rb_intern("div"); id_integer_p = rb_intern("integer?"); - id_to_i = rb_intern("to_i"); id_i_num = rb_intern("@numerator"); id_i_den = rb_intern("@denominator"); Index: variable.c =================================================================== --- variable.c (revision 62007) +++ variable.c (revision 62008) @@ -1748,7 +1748,7 @@ uninitialized_constant(VALUE klass, VALU https://github.com/ruby/ruby/blob/trunk/variable.c#L1748 VALUE rb_const_missing(VALUE klass, VALUE name) { - VALUE value = rb_funcallv(klass, rb_intern("const_missing"), 1, &name); + VALUE value = rb_funcallv(klass, idConst_missing, 1, &name); rb_vm_inc_const_missing_count(); return value; } Index: vm_eval.c =================================================================== --- vm_eval.c (revision 62007) +++ vm_eval.c (revision 62008) @@ -2150,9 +2150,9 @@ Init_vm_eval(void) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L2150 rb_define_private_method(rb_cBasicObject, "method_missing", rb_method_missing, -1); #if 1 - rb_add_method(rb_cBasicObject, rb_intern("__send__"), + rb_add_method(rb_cBasicObject, id__send__, VM_METHOD_TYPE_OPTIMIZED, (void *)OPTIMIZED_METHOD_TYPE_SEND, METHOD_VISI_PUBLIC); - rb_add_method(rb_mKernel, rb_intern("send"), + rb_add_method(rb_mKernel, idSend, VM_METHOD_TYPE_OPTIMIZED, (void *)OPTIMIZED_METHOD_TYPE_SEND, METHOD_VISI_PUBLIC); #else rb_define_method(rb_cBasicObject, "__send__", rb_f_send, -1); Index: io.c =================================================================== --- io.c (revision 62007) +++ io.c (revision 62008) @@ -4742,7 +4742,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/io.c#L4742 ignore_closed_stream(VALUE io, VALUE exc) { enum {mesg_len = sizeof(closed_stream)-1}; - VALUE mesg = rb_attr_get(exc, rb_intern("mesg")); + VALUE mesg = rb_attr_get(exc, idMesg); if (!RB_TYPE_P(mesg, T_STRING) || RSTRING_LEN(mesg) != mesg_len || memcmp(RSTRING_PTR(mesg), closed_stream, mesg_len)) { Index: dir.c =================================================================== --- dir.c (revision 62007) +++ dir.c (revision 62008) @@ -14,6 +14,7 @@ https://github.com/ruby/ruby/blob/trunk/dir.c#L14 #include "ruby/encoding.h" #include "ruby/thread.h" #include "internal.h" +#include "id.h" #include "encindex.h" #include <sys/types.h> @@ -662,7 +663,7 @@ dir_inspect(VALUE dir) https://github.com/ruby/ruby/blob/trunk/dir.c#L663 rb_str_cat2(str, ">"); return str; } - return rb_funcallv(dir, rb_intern("to_s"), 0, 0); + return rb_funcallv(dir, idTo_s, 0, 0); } /* Workaround for Solaris 10 that does not have dirfd. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/