aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--thread.c10
-rw-r--r--vm.c2
3 files changed, 12 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 6f9b737062..7642797a3a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
-Thu May 2 16:54:07 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu May 2 16:55:43 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * thread.c (id_locals): use cached ID.
+
+ * vm.c (ruby_thread_init): ditto.
* defs/id.def: add more predefined IDs used in core.
diff --git a/thread.c b/thread.c
index 1262f704b2..eaadaa889b 100644
--- a/thread.c
+++ b/thread.c
@@ -80,6 +80,7 @@ VALUE rb_cThreadShield;
static VALUE sym_immediate;
static VALUE sym_on_blocking;
static VALUE sym_never;
+static ID id_locals;
static void sleep_timeval(rb_thread_t *th, struct timeval time, int spurious_check);
static void sleep_wait_for_interrupt(rb_thread_t *th, double sleepsec, int spurious_check);
@@ -2898,7 +2899,7 @@ rb_thread_variable_get(VALUE thread, VALUE key)
}
if (!id) return Qnil;
- locals = rb_iv_get(thread, "locals");
+ locals = rb_ivar_get(thread, id_locals);
return rb_hash_aref(locals, ID2SYM(id));
}
@@ -2926,7 +2927,7 @@ rb_thread_variable_set(VALUE thread, VALUE id, VALUE val)
rb_error_frozen("thread locals");
}
- locals = rb_iv_get(thread, "locals");
+ locals = rb_ivar_get(thread, id_locals);
return rb_hash_aset(locals, ID2SYM(rb_to_id(id)), val);
}
@@ -3041,7 +3042,7 @@ rb_thread_variables(VALUE thread)
VALUE locals;
VALUE ary;
- locals = rb_iv_get(thread, "locals");
+ locals = rb_ivar_get(thread, id_locals);
ary = rb_ary_new();
rb_hash_foreach(locals, keys_i, ary);
@@ -3072,7 +3073,7 @@ rb_thread_variable_p(VALUE thread, VALUE key)
if (!id) return Qfalse;
- locals = rb_iv_get(thread, "locals");
+ locals = rb_ivar_get(thread, id_locals);
if (!RHASH(locals)->ntbl)
return Qfalse;
@@ -5013,6 +5014,7 @@ Init_Thread(void)
sym_never = ID2SYM(rb_intern("never"));
sym_immediate = ID2SYM(rb_intern("immediate"));
sym_on_blocking = ID2SYM(rb_intern("on_blocking"));
+ id_locals = rb_intern("locals");
rb_define_singleton_method(rb_cThread, "new", thread_s_new, -1);
rb_define_singleton_method(rb_cThread, "start", thread_start, -2);
diff --git a/vm.c b/vm.c
index c6c972032e..c467882323 100644
--- a/vm.c
+++ b/vm.c
@@ -1988,7 +1988,7 @@ ruby_thread_init(VALUE self)
th->vm = vm;
th_init(th, self);
- rb_iv_set(self, "locals", rb_hash_new());
+ rb_ivar_set(self, rb_intern("locals"), rb_hash_new());
th->top_wrapper = 0;
th->top_self = rb_vm_top_self();