From eb25f24c96f3902ecb790cf8f4fafc74ff9c637f Mon Sep 17 00:00:00 2001 From: Orkuncakilkaya Date: Mon, 28 Sep 2026 16:01:28 +0300 Subject: [PATCH] ludic.base: the growth paths push through kept_push, whose statement-level @alloc_ok says the bound Co-Authored-By: Claude Opus 5.5 --- packages/ludic.base/ecs_grid.ludic | 6 +++--- packages/ludic.base/ecs_index.ludic | 4 ++-- packages/ludic.base/ecs_table_reserve.ludic | 21 ++++++++++----------- packages/ludic.base/kept.ludic | 6 ++++-- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/packages/ludic.base/ecs_grid.ludic b/packages/ludic.base/ecs_grid.ludic index 3b18f2a8..176c0568 100644 --- a/packages/ludic.base/ecs_grid.ludic +++ b/packages/ludic.base/ecs_grid.ludic @@ -42,9 +42,9 @@ export function tb_grid(tb: Table, cx: int, cz: int, gate: int, cell: floa export function grid_count(g: Grid) -> int { return g.count } function grid_grow(g: Grid) -> void { - push(g.next, 0) - push(g.prev, 0) - push(g.key, -1) + kept_push(g.next, 0) + kept_push(g.prev, 0) + kept_push(g.key, -1) } function grid_shrink(g: Grid) -> void { diff --git a/packages/ludic.base/ecs_index.ludic b/packages/ludic.base/ecs_index.ludic index ab193162..4d2d4447 100644 --- a/packages/ludic.base/ecs_index.ludic +++ b/packages/ludic.base/ecs_index.ludic @@ -39,8 +39,8 @@ export function ix_first(ix: IntIndex, v: int) -> int { } function ix_grow(ix: IntIndex) -> void { - push(ix.pos, -1) - push(ix.val, -1) + kept_push(ix.pos, -1) + kept_push(ix.val, -1) } function ix_shrink(ix: IntIndex) -> void { diff --git a/packages/ludic.base/ecs_table_reserve.ludic b/packages/ludic.base/ecs_table_reserve.ludic index 2bc2a61b..d3a20d4e 100644 --- a/packages/ludic.base/ecs_table_reserve.ludic +++ b/packages/ludic.base/ecs_table_reserve.ludic @@ -20,24 +20,23 @@ export function tb_reserve(tb: Table, rows: int) -> void { for g in 0 .. len(tb.grids) { grid_reserve(tb.grids[g], rows) } } -# a row on every column, grid and index -@alloc_ok("past tb_reserve's rows only: a table grows to its high-water once and keeps it") +# a row on every column, grid and index; past tb_reserve's rows each is a kept list's growth function tb_push_row(tb: Table, r: T, h: int) -> void { - push(tb.rec, r) - push(tb.ent, h) - push(tb.added, tb.tick) - push(tb.changed, tb.tick) - for c in 0 .. len(tb.f) { push(tb.f[c], 0.0) } - for c in 0 .. len(tb.i) { push(tb.i[c], 0) } + kept_push(tb.rec, r) + kept_push(tb.ent, h) + kept_push(tb.added, tb.tick) + kept_push(tb.changed, tb.tick) + for c in 0 .. len(tb.f) { kept_push(tb.f[c], 0.0) } + for c in 0 .. len(tb.i) { kept_push(tb.i[c], 0) } tb.n += 1 for g in 0 .. len(tb.grids) { grid_grow(tb.grids[g]) } for k in 0 .. len(tb.idx) { ix_grow(tb.idx[k]) } } -@alloc_ok("past tb_reserve's rows only: a slot is made once and reused through the free list") +# a slot is made once and reused through the free list function tb_new_slot(tb: Table) -> int { let s = len(tb.slot_gen) - push(tb.slot_gen, 0) - push(tb.slot_row, -1) + kept_push(tb.slot_gen, 0) + kept_push(tb.slot_row, -1) return s } diff --git a/packages/ludic.base/kept.ludic b/packages/ludic.base/kept.ludic index a060f646..a801121f 100644 --- a/packages/ludic.base/kept.ludic +++ b/packages/ludic.base/kept.ludic @@ -1,4 +1,6 @@ # ludic.base/kept.ludic - the one push the frame is allowed: into a list its owner keeps and clears, # which grows to the most it has ever held and stays there (a queue's halves, a query's out list) -@alloc_ok("a kept list: it grows to the most it has held once, is cleared and reused, never dropped") -export function kept_push(xs: []T, v: T) -> void { push(xs, v) } +export function kept_push(xs: []T, v: T) -> void { + @alloc_ok("a kept list: it grows to the most it has held once, is cleared and reused, never dropped") + push(xs, v) +}