summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2025-10-17 17:28:55 -0400
committerPeter Zhu <peter@peterzhu.ca>2025-10-17 20:44:04 -0400
commit7989a2ff46e0dc8dc26b1571215768801fa04463 (patch)
tree6f4df1680277c3293665ac46115ea5389381e874 /class.c
parent9b2216954a34934fd855deb642a4369fc009c68a (diff)
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.
Diffstat (limited to 'class.c')
-rw-r--r--class.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/class.c b/class.c
index c8bf624140..77f2fba516 100644
--- a/class.c
+++ b/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);