Expand description
Process-wide cache of BC5D tables loaded from explicit filesystem paths.
The bridge/solve-json surfaces accept a caller-supplied table PATH (mobile apps
download the .bin themselves and hand the engine a file path), and PARSING a
several-MB table on every card or solve call would dominate the request. What the
cache saves is the parse; the read and CRC are the price of knowing what is
actually on disk.
Entries are keyed by (canonical path, file size, CRC32 of the file's bytes) —
i.e. by CONTENT. An earlier version keyed on (canonical path, file size, mtime)
and could serve a stale parsed table when a file was replaced in place by
same-size content within one filesystem mtime tick: the key was unchanged, so the
new bytes were never read. That is a live scenario here, not a theoretical one —
a table-set refresh overwrites bc5d_<caliber>.bin in place, and a regenerated
table with identical dimensions has identical size. It reached a release because
mtime granularity is fine enough on macOS and Linux to hide it, and only surfaced
on an OpenBSD guest whose granularity is coarse enough to collide.
Size is retained alongside the CRC purely as a second, free discriminator. The cache is bounded (oldest entry evicted at capacity).
Filesystem-only by construction, so the whole module is compiled out on
wasm32 (where WASM callers pass table BYTES via loadBc5dTable instead).
Functions§
- load_
verified - Load a BC5D table from
path, verifying the header (magic, version, dimensions) and the stored CRC32 exactly asBc5dTable::loaddoes, with the parsed result cached process-wide. - load_
verified_ for_ caliber load_verifiedplus the caliber-identity guard: the loaded table must be for the caliber of the shot that is about to use it, perBc5dTable::ensure_caliber_matches(shot_caliber_inin INCHES).