ludic.base: tb_reserve and imap_reserve size a table up front; HandlePool (a slot and a generation, nothing made after hd_pool_new, past its capacity a panic naming it); kept_push is the one declared grow, and every growth path left says its bound in @alloc_ok

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 15:58:11 +03:00
parent f2dd27f443
commit 2d1d06899e
17 changed files with 199 additions and 26 deletions

View file

@ -63,7 +63,7 @@ export function tb_within_recs<T>(tb: Table<T>, g: Grid, x: float, z: float, r:
let cells = (ix1 - ix0 + 1) * (iz1 - iz0 + 1)
if cells > g.count or cells < 0 {
for row in 0 .. len(g.key) {
if g.key[row] >= 0 and (mcol == null or mcol[row] == mv) and grid_d2(xs, zs, row, x, z) <= r * r { push(out, tb.rec[row]) }
if g.key[row] >= 0 and (mcol == null or mcol[row] == mv) and grid_d2(xs, zs, row, x, z) <= r * r { kept_push(out, tb.rec[row]) }
}
return len(out)
}
@ -78,7 +78,7 @@ function grid_recs_cell<T>(tb: Table<T>, g: Grid, xs: floats, zs: floats, mcol:
var r = g.head[grid_bucket(g, ix, iz)]
while r > 0 {
let row = r - 1
if g.key[row] == k and (mcol == null or mcol[row] == mv) and grid_d2(xs, zs, row, x, z) <= r2 { push(out, tb.rec[row]) }
if g.key[row] == k and (mcol == null or mcol[row] == mv) and grid_d2(xs, zs, row, x, z) <= r2 { kept_push(out, tb.rec[row]) }
r = g.next[row]
}
}
@ -95,7 +95,7 @@ export function tb_within_of_recs<T>(tb: Table<T>, g: Grid, ix: IntIndex, x: flo
for k in 0 .. n {
let row = rows[k]
if g.gate >= 0 and tb.i[g.gate][row] == 0 { continue }
if grid_d2(xs, zs, row, x, z) <= r * r { push(out, tb.rec[row]) }
if grid_d2(xs, zs, row, x, z) <= r * r { kept_push(out, tb.rec[row]) }
}
return len(out)
}