1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* include/ruby/ruby.h (rb_intern_const): tiny optimization.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-08-16 00:20:31 +00:00
parent c65dc8c3b1
commit 5f9c188d97
22 changed files with 35 additions and 6 deletions

View file

@ -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.

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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"));

View file

@ -1172,6 +1172,7 @@ void
Init_Encoding(void)
{
#undef rb_intern
#define rb_intern(str) rb_intern_const(str)
VALUE list;
int i;

1
enum.c
View file

@ -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");

1
hash.c
View file

@ -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");

1
id.c
View file

@ -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();

View file

@ -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);

1
io.c
View file

@ -7613,6 +7613,7 @@ void
Init_IO(void)
{
#undef rb_intern
#define rb_intern(str) rb_intern_const(str)
VALUE rb_cARGF;
#ifdef __CYGWIN__

12
load.c
View file

@ -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);

View file

@ -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");

View file

@ -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 */

View file

@ -2428,6 +2428,7 @@ void
Init_Object(void)
{
#undef rb_intern
#define rb_intern(str) rb_intern_const(str)
VALUE metaclass;

1
prec.c
View file

@ -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);

View file

@ -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");

View file

@ -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"));

View file

@ -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);

View file

@ -3525,6 +3525,7 @@ void
Init_Thread(void)
{
#undef rb_intern
#define rb_intern(str) rb_intern_const(str)
VALUE cThGroup;

1
time.c
View file

@ -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("*");

View file

@ -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);