Refined define_thread_class
Reduce duplications * ID caluculations of the same name * checks against the same name * registration to the root module hash
This commit is contained in:
parent
ac8c674a81
commit
b7d01b0d1b
@ -1554,10 +1554,10 @@ undumpable(VALUE obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
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);
|
VALUE klass = rb_define_class_id_under(outer, name, super);
|
||||||
rb_define_const(rb_cObject, name, klass);
|
rb_const_set(rb_cObject, name, klass);
|
||||||
return klass;
|
return klass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1573,7 +1573,7 @@ Init_thread_sync(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEFINE_CLASS(name, super) \
|
#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 */
|
/* Mutex */
|
||||||
DEFINE_CLASS(Mutex, Object);
|
DEFINE_CLASS(Mutex, Object);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user