From 11391aa01b2953a196828bfc46f0a75bed614c23 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 5 Apr 2013 15:21:02 +0000 Subject: thread.c: no allocate before deleting * thread.c (rb_thread_local_aset): no needs to allocate local_storage before deleting. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/thread.c b/thread.c index 350768f9b4..cd8021f1a1 100644 --- a/thread.c +++ b/thread.c @@ -2803,13 +2803,14 @@ rb_thread_local_aset(VALUE thread, ID id, VALUE val) if (OBJ_FROZEN(thread)) { rb_error_frozen("thread locals"); } - if (!th->local_storage) { - th->local_storage = st_init_numtable(); - } if (NIL_P(val)) { + if (!th->local_storage) return Qnil; st_delete_wrap(th->local_storage, id); return Qnil; } + if (!th->local_storage) { + th->local_storage = st_init_numtable(); + } st_insert(th->local_storage, id, val); return val; } -- cgit v1.2.3