ruby-changes:34582
From: nobu <ko1@a...>
Date: Thu, 3 Jul 2014 12:38:27 +0900 (JST)
Subject: [ruby-changes:34582] nobu:r46663 (trunk): Init functions don't need ID caches
nobu 2014-07-03 12:38:10 +0900 (Thu, 03 Jul 2014) New Revision: 46663 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46663 Log: Init functions don't need ID caches Modified files: trunk/class.c trunk/enumerator.c trunk/error.c trunk/gc.c trunk/random.c trunk/signal.c trunk/struct.c trunk/transcode.c trunk/variable.c Index: enumerator.c =================================================================== --- enumerator.c (revision 46662) +++ enumerator.c (revision 46663) @@ -2062,6 +2062,7 @@ InitVM_Enumerator(void) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L2062 rb_provide("enumerator.so"); /* for backward compatibility */ } +#undef rb_intern void Init_Enumerator(void) { Index: variable.c =================================================================== --- variable.c (revision 46662) +++ variable.c (revision 46663) @@ -27,13 +27,13 @@ void https://github.com/ruby/ruby/blob/trunk/variable.c#L27 Init_var_tables(void) { rb_global_tbl = st_init_numtable(); - CONST_ID(autoload, "__autoload__"); + autoload = rb_intern_const("__autoload__"); /* __classpath__: fully qualified class path */ - CONST_ID(classpath, "__classpath__"); + classpath = rb_intern_const("__classpath__"); /* __tmp_classpath__: temporary class path which contains anonymous names */ - CONST_ID(tmp_classpath, "__tmp_classpath__"); + tmp_classpath = rb_intern_const("__tmp_classpath__"); /* __classid__: name given to class/module under an anonymous namespace */ - CONST_ID(classid, "__classid__"); + classid = rb_intern_const("__classid__"); } struct fc_result { Index: struct.c =================================================================== --- struct.c (revision 46662) +++ struct.c (revision 46663) @@ -1064,7 +1064,7 @@ rb_struct_size(VALUE s) https://github.com/ruby/ruby/blob/trunk/struct.c#L1064 * Symbol (<code>:name</code>). */ void -Init_Struct(void) +InitVM_Struct(void) { rb_cStruct = rb_define_class("Struct", rb_cObject); rb_include_module(rb_cStruct, rb_mEnumerable); @@ -1095,5 +1095,13 @@ Init_Struct(void) https://github.com/ruby/ruby/blob/trunk/struct.c#L1095 rb_define_method(rb_cStruct, "values_at", rb_struct_values_at, -1); rb_define_method(rb_cStruct, "members", rb_struct_members_m, 0); +} + +#undef rb_intern +void +Init_Struct(void) +{ id_members = rb_intern("__members__"); + + InitVM(Struct); } Index: gc.c =================================================================== --- gc.c (revision 46662) +++ gc.c (revision 46663) @@ -7749,6 +7749,7 @@ rb_gcdebug_sentinel(VALUE obj, const cha https://github.com/ruby/ruby/blob/trunk/gc.c#L7749 void Init_GC(void) { +#undef rb_intern VALUE rb_mObjSpace; VALUE rb_mProfiler; VALUE gc_constants; Index: class.c =================================================================== --- class.c (revision 46662) +++ class.c (revision 46663) @@ -539,7 +539,7 @@ Init_class_hierarchy(void) https://github.com/ruby/ruby/blob/trunk/class.c#L539 rb_cModule = boot_defclass("Module", rb_cObject); rb_cClass = boot_defclass("Class", rb_cModule); - rb_const_set(rb_cObject, rb_intern("BasicObject"), rb_cBasicObject); + rb_const_set(rb_cObject, rb_intern_const("BasicObject"), rb_cBasicObject); RBASIC_SET_CLASS(rb_cClass, rb_cClass); RBASIC_SET_CLASS(rb_cModule, rb_cClass); RBASIC_SET_CLASS(rb_cObject, rb_cClass); Index: error.c =================================================================== --- error.c (revision 46662) +++ error.c (revision 46663) @@ -1856,7 +1856,7 @@ Init_Exception(void) https://github.com/ruby/ruby/blob/trunk/error.c#L1856 rb_eLoadError = rb_define_class("LoadError", rb_eScriptError); /* the path failed to load */ - rb_attr(rb_eLoadError, rb_intern("path"), 1, 0, Qfalse); + rb_attr(rb_eLoadError, rb_intern_const("path"), 1, 0, Qfalse); rb_eNotImpError = rb_define_class("NotImplementedError", rb_eScriptError); Index: signal.c =================================================================== --- signal.c (revision 46662) +++ signal.c (revision 46663) @@ -1312,7 +1312,7 @@ Init_signal(void) https://github.com/ruby/ruby/blob/trunk/signal.c#L1312 rb_define_method(rb_eSignal, "initialize", esignal_init, -1); rb_define_method(rb_eSignal, "signo", esignal_signo, 0); - rb_alias(rb_eSignal, rb_intern("signm"), rb_intern("message")); + rb_alias(rb_eSignal, rb_intern_const("signm"), rb_intern_const("message")); rb_define_method(rb_eInterrupt, "initialize", interrupt_init, -1); install_sighandler(SIGINT, sighandler); Index: random.c =================================================================== --- random.c (revision 46662) +++ random.c (revision 46663) @@ -1352,7 +1352,7 @@ rb_reset_random_seed(void) https://github.com/ruby/ruby/blob/trunk/random.c#L1352 */ void -Init_Random(void) +InitVM_Random(void) { Init_RandomSeed2(); rb_define_global_function("srand", rb_f_srand, -1); @@ -1383,7 +1383,14 @@ Init_Random(void) https://github.com/ruby/ruby/blob/trunk/random.c#L1383 rb_define_singleton_method(rb_cRandom, "new_seed", random_seed, 0); rb_define_private_method(CLASS_OF(rb_cRandom), "state", random_s_state, 0); rb_define_private_method(CLASS_OF(rb_cRandom), "left", random_s_left, 0); +} +#undef rb_intern +void +Init_Random(void) +{ id_rand = rb_intern("rand"); id_bytes = rb_intern("bytes"); + + InitVM(Random); } Index: transcode.c =================================================================== --- transcode.c (revision 46662) +++ transcode.c (revision 46663) @@ -4388,13 +4388,10 @@ ecerr_incomplete_input(VALUE self) https://github.com/ruby/ruby/blob/trunk/transcode.c#L4388 * correspond with a known converter. */ +#undef rb_intern void Init_transcode(void) { - rb_eUndefinedConversionError = rb_define_class_under(rb_cEncoding, "UndefinedConversionError", rb_eEncodingError); - rb_eInvalidByteSequenceError = rb_define_class_under(rb_cEncoding, "InvalidByteSequenceError", rb_eEncodingError); - rb_eConverterNotFoundError = rb_define_class_under(rb_cEncoding, "ConverterNotFoundError", rb_eEncodingError); - transcoder_table = st_init_strcasetable(); sym_invalid = ID2SYM(rb_intern("invalid")); @@ -4426,6 +4423,16 @@ Init_transcode(void) https://github.com/ruby/ruby/blob/trunk/transcode.c#L4423 sym_lf = ID2SYM(rb_intern("lf")); #endif + InitVM(transcode); +} + +void +InitVM_transcode(void) +{ + rb_eUndefinedConversionError = rb_define_class_under(rb_cEncoding, "UndefinedConversionError", rb_eEncodingError); + rb_eInvalidByteSequenceError = rb_define_class_under(rb_cEncoding, "InvalidByteSequenceError", rb_eEncodingError); + rb_eConverterNotFoundError = rb_define_class_under(rb_cEncoding, "ConverterNotFoundError", rb_eEncodingError); + rb_define_method(rb_cString, "encode", str_encode, -1); rb_define_method(rb_cString, "encode!", str_encode_bang, -1); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/