Skip to main content

Module xml

Module xml 

Source
Expand description

A compact, arena-backed XML tree tuned for XTCE.

§Why a tree and not a pure SAX pass

XTCE is not a stream: <BaseContainer> points backwards or forwards, <ParameterRefEntry> names types defined earlier or later, and several elements are only meaningful together with siblings. A single streaming pass would need a hand-rolled state machine with a deferred-fixup table for every one of those cases. Building a tree first keeps the semantic pass declarative (node.child(Tag::EntryList)) at the cost of one compact arena.

§Why it is still fast

Nothing here allocates per element. Element names, attribute names, attribute values and text are appended to one shared String arena and addressed by (start, len), so the tree is three flat Vecs of Copy records with no String, no Rc, and no per-node allocation.

The arena deliberately does not deduplicate. An earlier version interned every attribute value, which sounds attractive — encoding="unsigned" appears 205 times in one test file — but interning costs a hash lookup per value where the arena costs a memcpy of about eight bytes, and the 1.6 MB test file has roughly a quarter of a million of them. Deduplication belongs in the IR, which keeps only the names it actually needs; the tree is transient and is dropped as soon as lowering finishes.

Tag and attribute-key recognition is a match on the local name rather than a hash lookup: the vocabulary is a small closed set of short strings, which rustc compiles into a length switch and a handful of comparisons.

Structs§

Children
Iterator over the direct children of an element.
Dom
A parsed XTCE document: a flat arena of elements plus the interner backing every name.
Element
A borrowed handle to one element, carrying the arena it came from.
Node
One element in the arena.

Enums§

AttrKey
XTCE attribute names that carry meaning for telemetry decoding.
Tag
XTCE element local names that carry meaning for telemetry decoding.