ruby-changes:3395
From: ko1@a...
Date: 5 Jan 2008 02:22:06 +0900
Subject: [ruby-changes:3395] akr - Ruby:r14888 (trunk): * include/ruby/ruby.h (rb_intern): memorize interned ID for constant
akr 2008-01-05 02:21:53 +0900 (Sat, 05 Jan 2008) New Revision: 14888 Modified files: trunk/ChangeLog trunk/include/ruby/ruby.h trunk/parse.y Log: * include/ruby/ruby.h (rb_intern): memorize interned ID for constant string, using gcc's __builtin_constant_p and statement expression. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/include/ruby/ruby.h?r1=14888&r2=14887&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/parse.y?r1=14888&r2=14887&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14888&r2=14887&diff_format=u Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 14887) +++ include/ruby/ruby.h (revision 14888) @@ -719,6 +719,20 @@ ID rb_to_id(VALUE); VALUE rb_id2str(ID); +#ifdef __GNUC__ +/* __builtin_constant_p and statement expression is available + * since gcc-2.7.2.3 at least. */ +#define rb_intern(str) \ + (__builtin_constant_p(str) ? \ + ({ \ + static ID rb_intern_id_cache; \ + if (!rb_intern_id_cache) \ + rb_intern_id_cache = rb_intern(str); \ + rb_intern_id_cache; \ + }) : \ + rb_intern(str)) +#endif + char *rb_class2name(VALUE); char *rb_obj_classname(VALUE); Index: ChangeLog =================================================================== --- ChangeLog (revision 14887) +++ ChangeLog (revision 14888) @@ -1,3 +1,8 @@ +Sat Jan 5 02:21:10 2008 Tanaka Akira <akr@f...> + + * include/ruby/ruby.h (rb_intern): memorize interned ID for constant + string, using gcc's __builtin_constant_p and statement expression. + Sat Jan 5 02:14:45 2008 Yukihiro Matsumoto <matz@r...> * string.c (trnext): should enable backslash escape. Index: parse.y =================================================================== --- parse.y (revision 14887) +++ parse.y (revision 14888) @@ -9001,6 +9001,7 @@ return rb_intern3(name, len, rb_enc_from_index(0)); } +#undef rb_intern ID rb_intern(const char *name) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml