ruby-changes:66618
From: Nobuyoshi <ko1@a...>
Date: Mon, 28 Jun 2021 18:42:54 +0900 (JST)
Subject: [ruby-changes:66618] b7d01b0d1b (master): Refined define_thread_class
https://git.ruby-lang.org/ruby.git/commit/?id=b7d01b0d1b From b7d01b0d1bf0526e12e01c58963453f9711c67b5 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 28 Jun 2021 16:52:49 +0900 Subject: Refined define_thread_class Reduce duplications * ID caluculations of the same name * checks against the same name * registration to the root module hash --- thread_sync.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/thread_sync.c b/thread_sync.c index c6183ca..f78b0b5 100644 --- a/thread_sync.c +++ b/thread_sync.c @@ -1554,10 +1554,10 @@ undumpable(VALUE obj) https://github.com/ruby/ruby/blob/trunk/thread_sync.c#L1554 } static VALUE -define_thread_class(VALUE outer, const char *name, VALUE super) +define_thread_class(VALUE outer, const ID name, VALUE super) { - VALUE klass = rb_define_class_under(outer, name, super); - rb_define_const(rb_cObject, name, klass); + VALUE klass = rb_define_class_id_under(outer, name, super); + rb_const_set(rb_cObject, name, klass); return klass; } @@ -1573,7 +1573,7 @@ Init_thread_sync(void) https://github.com/ruby/ruby/blob/trunk/thread_sync.c#L1573 #endif #define DEFINE_CLASS(name, super) \ - rb_c##name = define_thread_class(rb_cThread, #name, rb_c##super) + rb_c##name = define_thread_class(rb_cThread, rb_intern(#name), rb_c##super) /* Mutex */ DEFINE_CLASS(Mutex, Object); -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/