ruby-changes:49589
From: normal <ko1@a...>
Date: Tue, 9 Jan 2018 11:45:11 +0900 (JST)
Subject: [ruby-changes:49589] normal:r61704 (trunk): use predefined ids in a few more places
normal 2018-01-09 11:45:03 +0900 (Tue, 09 Jan 2018) New Revision: 61704 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61704 Log: use predefined ids in a few more places Saves a little space on x86: text data bss dec hex filename 3684110 11968 34240 3730318 38eb8e ruby.before 3684086 11968 34240 3730294 38eb76 ruby.after * enumerator.c: include id.h, define aliases (Init_Enumeerator): remove unnecessary rb_intern calls * gc.c (should_be_callable): use idCall * vm.c (Init_VM): ditto Modified files: trunk/enumerator.c trunk/gc.c trunk/vm.c Index: enumerator.c =================================================================== --- enumerator.c (revision 61703) +++ enumerator.c (revision 61704) @@ -13,6 +13,7 @@ https://github.com/ruby/ruby/blob/trunk/enumerator.c#L13 ************************************************/ #include "internal.h" +#include "id.h" /* * Document-class: Enumerator @@ -102,10 +103,16 @@ https://github.com/ruby/ruby/blob/trunk/enumerator.c#L103 */ VALUE rb_cEnumerator; VALUE rb_cLazy; -static ID id_rewind, id_each, id_new, id_initialize, id_yield, id_call, id_size, id_to_enum; -static ID id_eqq, id_next, id_result, id_lazy, id_receiver, id_arguments, id_memo, id_method, id_force; +static ID id_rewind, id_new, id_yield, id_to_enum; +static ID id_next, id_result, id_lazy, id_receiver, id_arguments, id_memo, id_method, id_force; static VALUE sym_each, sym_cycle; +#define id_call idCall +#define id_each idEach +#define id_eqq idEqq +#define id_initialize idInitialize +#define id_size idSize + VALUE rb_eStopIteration; struct enumerator { @@ -2414,16 +2421,11 @@ void https://github.com/ruby/ruby/blob/trunk/enumerator.c#L2421 Init_Enumerator(void) { id_rewind = rb_intern("rewind"); - id_each = rb_intern("each"); - id_call = rb_intern("call"); - id_size = rb_intern("size"); id_yield = rb_intern("yield"); id_new = rb_intern("new"); - id_initialize = rb_intern("initialize"); id_next = rb_intern("next"); id_result = rb_intern("result"); id_lazy = rb_intern("lazy"); - id_eqq = rb_intern("==="); id_receiver = rb_intern("receiver"); id_arguments = rb_intern("arguments"); id_memo = rb_intern("memo"); Index: gc.c =================================================================== --- gc.c (revision 61703) +++ gc.c (revision 61704) @@ -2669,7 +2669,7 @@ rb_undefine_finalizer(VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L2669 static void should_be_callable(VALUE block) { - if (!rb_obj_respond_to(block, rb_intern("call"), TRUE)) { + if (!rb_obj_respond_to(block, idCall, TRUE)) { rb_raise(rb_eArgError, "wrong type argument %"PRIsVALUE" (should be callable)", rb_obj_class(block)); } Index: vm.c =================================================================== --- vm.c (revision 61703) +++ vm.c (revision 61704) @@ -3076,7 +3076,7 @@ Init_VM(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L3076 vm_init_redefined_flag(); rb_block_param_proxy = rb_obj_alloc(rb_cObject); - rb_add_method(rb_singleton_class(rb_block_param_proxy), rb_intern("call"), VM_METHOD_TYPE_OPTIMIZED, + rb_add_method(rb_singleton_class(rb_block_param_proxy), idCall, VM_METHOD_TYPE_OPTIMIZED, (void *)OPTIMIZED_METHOD_TYPE_BLOCK_CALL, METHOD_VISI_PUBLIC); rb_obj_freeze(rb_block_param_proxy); rb_gc_register_mark_object(rb_block_param_proxy); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/