Performance
Faster packrat parsing with an open-addressing memoization cache
- Replaced the packrat memoization cache (previously a
std::map) withPackratCache: a flat open-addressing hash table with linear probing, fused(position * rule_count + rule_id)keys, a lazily allocated semantic-value array, and an input-length-based initial capacity that all but eliminates rehashing. - Cache the tracer-availability check as a
boolcomputed once at parse start, instead of re-deriving it on every operator visit. - Replaced the per-byte locale
tolowerwith a lookup table frozen at parse start, used by both literal matching and the keyword guard. - Switched the semantic value stack to
unique_ptr.
These changes cut big.sql parse time from 3.4x → 2.0x relative to the YACC (libpg_query) baseline. The same optimizations were ported to rust-peglib, yielding ~17% faster TPC-H queries.
Bug Fixes
Fix MiniJsTest being skipped when run from non-standard directories (#341)
find_grammar()only searchedspec/mini-js/grammar.pegwith the relative prefixes"","../", and"../../"from the current working directory. When the test binary ran from a directory that was not 0–2 levels below the repo root (e.g. nested build trees or package builds such as FreeBSD ports), the grammar file was not found,SetUpTestSuite()threw, and GoogleTest reported all 70MiniJsTestcases as Skipped.- The absolute grammar path is now passed via the
MINI_JS_GRAMMAR_PATHcompile definition and used as the primary candidate, falling back to the existing relative search.
Full Changelog: v1.11.0...v1.12.0