From b7d01b0d1bf0526e12e01c58963453f9711c67b5 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 28 Jun 2021 16:52:49 +0900 Subject: [PATCH] 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 c6183ca438..f78b0b5357 100644 --- a/thread_sync.c +++ b/thread_sync.c @@ -1554,10 +1554,10 @@ undumpable(VALUE obj) } 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) #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);