ludic.base: the growth paths push through kept_push, whose statement-level @alloc_ok says the bound
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3f32bfda7c
commit
eb25f24c96
4 changed files with 19 additions and 18 deletions
|
|
@ -20,24 +20,23 @@ export function tb_reserve<T>(tb: Table<T>, 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<T>(tb: Table<T>, 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<T>(tb: Table<T>) -> 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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue