[前][次][番号順一覧][スレッド一覧]

ruby-changes:28505

From: nobu <ko1@a...>
Date: Thu, 2 May 2013 16:57:16 +0900 (JST)
Subject: [ruby-changes:28505] nobu:r40557 (trunk): thread.c: id locals

nobu	2013-05-02 16:55:50 +0900 (Thu, 02 May 2013)

  New Revision: 40557

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40557

  Log:
    thread.c: id locals
    
    * thread.c (id_locals): use cached ID.
    * vm.c (ruby_thread_init): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/thread.c
    trunk/vm.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40556)
+++ ChangeLog	(revision 40557)
@@ -1,4 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Thu May  2 16:54:07 2013  Nobuyoshi Nakada  <nobu@r...>
+Thu May  2 16:55:43 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* thread.c (id_locals): use cached ID.
+
+	* vm.c (ruby_thread_init): ditto.
 
 	* defs/id.def: add more predefined IDs used in core.
 
Index: thread.c
===================================================================
--- thread.c	(revision 40556)
+++ thread.c	(revision 40557)
@@ -80,6 +80,7 @@ VALUE rb_cThreadShield; https://github.com/ruby/ruby/blob/trunk/thread.c#L80
 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, VAL https://github.com/ruby/ruby/blob/trunk/thread.c#L2899
     }
 
     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, VAL https://github.com/ruby/ruby/blob/trunk/thread.c#L2927
 	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) https://github.com/ruby/ruby/blob/trunk/thread.c#L3042
     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 https://github.com/ruby/ruby/blob/trunk/thread.c#L3073
 
     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) https://github.com/ruby/ruby/blob/trunk/thread.c#L5014
     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);
Index: vm.c
===================================================================
--- vm.c	(revision 40556)
+++ vm.c	(revision 40557)
@@ -1988,7 +1988,7 @@ ruby_thread_init(VALUE self) https://github.com/ruby/ruby/blob/trunk/vm.c#L1988
 
     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();

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]