mirror of
https://github.com/ruby/ruby.git
synced 2025-09-21 03:24:00 +02:00
* include/ruby/ruby.h (rb_intern): memorize interned ID for constant
string, using gcc's __builtin_constant_p and statement expression. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f3fa37e8e5
commit
9eab58ee03
3 changed files with 20 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Jan 5 02:21:10 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* 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@ruby-lang.org>
|
Sat Jan 5 02:14:45 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* string.c (trnext): should enable backslash escape.
|
* string.c (trnext): should enable backslash escape.
|
||||||
|
|
|
@ -719,6 +719,20 @@ const char *rb_id2name(ID);
|
||||||
ID rb_to_id(VALUE);
|
ID rb_to_id(VALUE);
|
||||||
VALUE rb_id2str(ID);
|
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_class2name(VALUE);
|
||||||
char *rb_obj_classname(VALUE);
|
char *rb_obj_classname(VALUE);
|
||||||
|
|
||||||
|
|
1
parse.y
1
parse.y
|
@ -9001,6 +9001,7 @@ rb_intern2(const char *name, long len)
|
||||||
return rb_intern3(name, len, rb_enc_from_index(0));
|
return rb_intern3(name, len, rb_enc_from_index(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef rb_intern
|
||||||
ID
|
ID
|
||||||
rb_intern(const char *name)
|
rb_intern(const char *name)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue