From 31457774a88cae0fcf95d1e2ca517b6c2e8f91ee Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 2 May 2013 07:55:50 +0000 Subject: thread.c: id locals * thread.c (id_locals): use cached ID. * vm.c (ruby_thread_init): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'thread.c') 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); -- cgit v1.2.3