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
|
|
@ -42,9 +42,9 @@ export function tb_grid<T>(tb: Table<T>, 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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<T>(xs: []T, v: T) -> void { push(xs, v) }
|
||||
export function kept_push<T>(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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue