From: Benoit Daloze Date: 2010-10-14T22:09:44+09:00 Subject: [ruby-core:32786] Re: replacing rb_intern 2010/10/14 Ond��ej B��lka : > Hello > > I have idea to speed up ruby a bit > > Typical use of rb_intern looks like this > ��if (!rb_respond_to(str2, rb_intern("to_str"))) { > �� �� �� �� �� �� ��return Qfalse; > > which could be replaced by > ��if (!rb_respond_to(str2, id_to_str)) { > �� �� �� �� �� �� �� ��return Qfalse; > > I propose to use script which replaces all occurences of rb_intern("foo") by id_foo, defines id_foo and initializes it at Init_ function. > > Any comments? AFAIK, this is already done in Ruby. Check complex.c for example (in 1.9). However, it is not done everywhere. One reason might be readability ("<=") and small performance gain. It might be worth to be asked on ruby-core. Regards, B.D.