summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--array.c1
-rw-r--r--compar.c1
-rw-r--r--compile.c1
-rw-r--r--complex.c1
-rw-r--r--encoding.c1
-rw-r--r--enum.c1
-rw-r--r--hash.c1
-rw-r--r--id.c1
-rw-r--r--include/ruby/ruby.h6
-rw-r--r--io.c1
-rw-r--r--load.c12
-rw-r--r--marshal.c1
-rw-r--r--numeric.c1
-rw-r--r--object.c1
-rw-r--r--prec.c1
-rw-r--r--range.c1
-rw-r--r--rational.c1
-rw-r--r--string.c1
-rw-r--r--thread.c1
-rw-r--r--time.c1
-rw-r--r--vm_method.c1
22 files changed, 35 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index a88a77d..80a49d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,6 @@
-Sat Aug 16 08:52:55 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Aug 16 09:20:18 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * include/ruby/ruby.h (rb_intern_const): tiny optimization.
* include/ruby/ruby.h (SSIZET2NUM, NUM2SSIZET, SSIZE_MAX, SSIZE_MIN):
macros for ssize_t.
diff --git a/array.c b/array.c
index 941f3ff..0b7427c 100644
--- a/array.c
+++ b/array.c
@@ -3476,6 +3476,7 @@ void
Init_Array(void)
{
#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
rb_cArray = rb_define_class("Array", rb_cObject);
rb_include_module(rb_cArray, rb_mEnumerable);
diff --git a/compar.c b/compar.c
index b028a25..633c5b5 100644
--- a/compar.c
+++ b/compar.c
@@ -199,6 +199,7 @@ void
Init_Comparable(void)
{
#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
rb_mComparable = rb_define_module("Comparable");
rb_define_method(rb_mComparable, "==", cmp_equal, 1);
diff --git a/compile.c b/compile.c
index 993ebd0..83598b4 100644
--- a/compile.c
+++ b/compile.c
@@ -4806,6 +4806,7 @@ static VALUE
get_exception_sym2type(VALUE sym)
{
#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
static VALUE symRescue, symEnsure, symRetry;
static VALUE symBreak, symRedo, symNext;
diff --git a/complex.c b/complex.c
index 281cb8c..707383a 100644
--- a/complex.c
+++ b/complex.c
@@ -1364,6 +1364,7 @@ void
Init_Complex(void)
{
#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
assert(fprintf(stderr, "assert() is now active\n"));
diff --git a/encoding.c b/encoding.c
index ca08416..9002a1f 100644
--- a/encoding.c
+++ b/encoding.c
@@ -1172,6 +1172,7 @@ void
Init_Encoding(void)
{
#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
VALUE list;
int i;
diff --git a/enum.c b/enum.c
index b704732..9a77f34 100644
--- a/enum.c
+++ b/enum.c
@@ -1803,6 +1803,7 @@ void
Init_Enumerable(void)
{
#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
rb_mEnumerable = rb_define_module("Enumerable");
diff --git a/hash.c b/hash.c
index bb43ccb..9e0831d 100644
--- a/hash.c
+++ b/hash.c
@@ -2597,6 +2597,7 @@ void
Init_Hash(void)
{
#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
id_hash = rb_intern("hash");
id_yield = rb_intern("yield");
diff --git a/id.c b/id.c
index c34f0c8..57c965a 100644
--- a/id.c
+++ b/id.c
@@ -17,6 +17,7 @@ static void
Init_id(void)
{
#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
#define rb_intern(str) rb_intern2(str, strlen(str))
rb_encoding *enc = rb_usascii_encoding();
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 57610a5..a472ea9 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -830,6 +830,12 @@ VALUE rb_id2str(ID);
(__builtin_constant_p(str) ? \
__extension__ (CONST_ID_CACHE(/**/, str)) : \
rb_intern(str))
+#define rb_intern_const(str) \
+ (__builtin_constant_p(str) ? \
+ __extension__ (rb_intern2(str, strlen(str))) : \
+ (rb_intern)(str))
+#else
+#define rb_intern_const(str) rb_intern2(str, strlen(str))
#endif
const char *rb_class2name(VALUE);
diff --git a/io.c b/io.c
index 08578cf..1b3f8c7 100644
--- a/io.c
+++ b/io.c
@@ -7613,6 +7613,7 @@ void
Init_IO(void)
{
#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
VALUE rb_cARGF;
#ifdef __CYGWIN__
diff --git a/load.c b/load.c
index b9c8a37..a6daff4 100644
--- a/load.c
+++ b/load.c
@@ -675,13 +675,15 @@ rb_f_autoload_p(VALUE obj, VALUE sym)
void
Init_load()
{
+#undef rb_intern
+#define rb_intern(str) rb_intern2(str, strlen(str))
rb_vm_t *vm = GET_VM();
- const char *var_load_path = "$:";
- ID id_load_path = rb_intern(var_load_path);
+ static const char var_load_path[] = "$:";
+ ID id_load_path = rb_intern2(var_load_path, sizeof(var_load_path)-1);
- rb_define_hooked_variable(var_load_path, (VALUE*)GET_VM(), load_path_getter, 0);
- rb_alias_variable((rb_intern)("$-I"), id_load_path);
- rb_alias_variable((rb_intern)("$LOAD_PATH"), id_load_path);
+ rb_define_hooked_variable(var_load_path, (VALUE*)vm, load_path_getter, 0);
+ rb_alias_variable(rb_intern("$-I"), id_load_path);
+ rb_alias_variable(rb_intern("$LOAD_PATH"), id_load_path);
vm->load_path = rb_ary_new();
rb_define_virtual_variable("$\"", get_loaded_features, 0);
diff --git a/marshal.c b/marshal.c
index 1ed67ad..0909add 100644
--- a/marshal.c
+++ b/marshal.c
@@ -1689,6 +1689,7 @@ void
Init_marshal(void)
{
#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
VALUE rb_mMarshal = rb_define_module("Marshal");
diff --git a/numeric.c b/numeric.c
index 2b5890c..25e169a 100644
--- a/numeric.c
+++ b/numeric.c
@@ -3106,6 +3106,7 @@ void
Init_Numeric(void)
{
#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
#if defined(__FreeBSD__) && __FreeBSD__ < 4
/* allow divide by zero -- Inf */
diff --git a/object.c b/object.c
index e4fcf77..3c95ef9 100644
--- a/object.c
+++ b/object.c
@@ -2428,6 +2428,7 @@ void
Init_Object(void)
{
#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
VALUE metaclass;
diff --git a/prec.c b/prec.c
index 3b24524..84de958 100644
--- a/prec.c
+++ b/prec.c
@@ -125,6 +125,7 @@ void
Init_Precision(void)
{
#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
rb_mPrecision = rb_define_module("Precision");
rb_define_singleton_method(rb_mPrecision, "included", prec_included, 1);
diff --git a/range.c b/range.c
index 3b19a2b..bbf9830 100644
--- a/range.c
+++ b/range.c
@@ -897,6 +897,7 @@ void
Init_Range(void)
{
#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
id_cmp = rb_intern("<=>");
id_succ = rb_intern("succ");
diff --git a/rational.c b/rational.c
index 48ed7eae..19bb037 100644
--- a/rational.c
+++ b/rational.c
@@ -1470,6 +1470,7 @@ void
Init_Rational(void)
{
#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
assert(fprintf(stderr, "assert() is now active\n"));
diff --git a/string.c b/string.c
index 10ac53b..0451a7c 100644
--- a/string.c
+++ b/string.c
@@ -6611,6 +6611,7 @@ void
Init_String(void)
{
#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
rb_cString = rb_define_class("String", rb_cObject);
rb_include_module(rb_cString, rb_mComparable);
diff --git a/thread.c b/thread.c
index 78d7d8b..14c2a89 100644
--- a/thread.c
+++ b/thread.c
@@ -3525,6 +3525,7 @@ void
Init_Thread(void)
{
#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
VALUE cThGroup;
diff --git a/time.c b/time.c
index b3eabbc..cf7ca22 100644
--- a/time.c
+++ b/time.c
@@ -2353,6 +2353,7 @@ void
Init_Time(void)
{
#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
id_divmod = rb_intern("divmod");
id_mul = rb_intern("*");
diff --git a/vm_method.c b/vm_method.c
index d3f38d7..0254741 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -1114,6 +1114,7 @@ void
Init_eval_method(void)
{
#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
rb_define_method(rb_mKernel, "respond_to?", obj_respond_to, -1);