mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 04:24:23 +00:00
Preallocate capacity for id table in rb_singleton_class_clone_and_attach
We know the exact capacity for the constant table created in rb_singleton_class_clone_and_attach so we can preallocate it.
This commit is contained in:
parent
9b2216954a
commit
7989a2ff46
Notes:
git
2025-10-18 00:44:36 +00:00
2
class.c
2
class.c
@ -1193,7 +1193,7 @@ rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach)
|
||||
if (RCLASS_CONST_TBL(klass)) {
|
||||
struct clone_const_arg arg;
|
||||
struct rb_id_table *table;
|
||||
arg.tbl = table = rb_id_table_create(0);
|
||||
arg.tbl = table = rb_id_table_create(rb_id_table_size(RCLASS_CONST_TBL(klass)));
|
||||
arg.klass = clone;
|
||||
rb_id_table_foreach(RCLASS_CONST_TBL(klass), clone_const_i, &arg);
|
||||
RCLASS_SET_CONST_TBL(clone, table, false);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user