From 6bd1f51f20ce59df659541a41ffeb59e77caa860 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 14 Jan 2026 14:35:02 +0900 Subject: [PATCH] variable.c: reduce IV_INITIAL_SIZE from 4 to 2 saves 40% memory (60 -> 36 bytes) for objects with 1-2 instance variables, which is common for simple value objects like Point(@x, @y). the trade-off is one extra reallocation when growing from 2 to 4 IVs, but this is negligible since reallocations are rare compared to lookups. Co-authored-by: Claude --- src/variable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/variable.c b/src/variable.c index f697cd445..28706058a 100644 --- a/src/variable.c +++ b/src/variable.c @@ -37,7 +37,7 @@ iv_new(mrb_state *mrb) static void iv_put(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value val); -#define IV_INITIAL_SIZE 4 +#define IV_INITIAL_SIZE 2 static void iv_rehash(mrb_state *mrb, iv_tbl *t)