Skip to content

Commit 6bd1f51

Browse files
matzclaude
andcommitted
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 <noreply@anthropic.com>
1 parent 9962080 commit 6bd1f51

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/variable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ iv_new(mrb_state *mrb)
3737

3838
static void iv_put(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value val);
3939

40-
#define IV_INITIAL_SIZE 4
40+
#define IV_INITIAL_SIZE 2
4141

4242
static void
4343
iv_rehash(mrb_state *mrb, iv_tbl *t)

0 commit comments

Comments
 (0)