Files
codeql/shared
Taus 15936a5f8d yeast: Take fields by ownership in apply_rules_inner
Previously, apply_rules_inner snapshotted a node's fields by cloning
the BTreeMap into a Vec<(FieldId, Vec<Id>)>, then built a fresh
BTreeMap of new_fields for the rewritten Ids. For a node with N
fields, this allocated 2N+1 things per visit (the snapshot Vec, N
cloned children Vecs, the new BTreeMap entries) — even when nothing
in the subtree was rewritten.

Use std::mem::take to swap the parent's fields out by ownership: the
recursion can mutate the AST (including pushing new nodes from rule
firings) without any conflict, since we hold the owned BTreeMap
locally. Iterate values_mut() and only allocate a fresh children Vec
on the first divergence (lazy alloc): unchanged children stay in the
existing slot. When done, swap the fields back.

For a subtree with no rewrites, this is now zero allocations per node
(modulo the recursion itself). For nodes with rewrites, it's one Vec
allocation per field that contains a rewritten child, instead of two
plus the BTreeMap rebuild.
2026-05-08 12:48:10 +00:00
..

CodeQL Shared Libraries

This folder contains shared, language-agnostic CodeQL libraries.

Libraries are organized into separate query packs, in order to allow for individual versioning. For example, the shared static single assignment (SSA) library exists in the codeql/ssa pack, which can be referenced by adding

dependencies:
  codeql/ssa: 0.0.1

to qlpack.yml.

All shared libraries will belong to a codeql/<name> pack, and live in the namespace codeql.<name>.