Building the mutable TreeNode tree from a parsed value Node ran append for every child. append -> insert detaches the child from any previous parent, rejects a self/ancestor cycle, and inserts into a children array that grows element by element. The children the conversion passes come from element.children.map and are freshly built and parentless, so all three guards are no-ops and the incremental growth rebuilds an array that was already prepared. TreeNode.init(adopting:) adopts the prepared array directly and wires each child's parent. The tree is identical: the same children in the same order with the same parent links. The adopting initializer is used only by the value-Node conversion; every public factory keeps the detaching, cycle-checking append path for externally supplied children that may already live in a tree. Measured parse ~12% faster on the 20k-item generated corpus via a same-state A/B (7.7x to ~6.5x slower than libxml2). Verified by TreeNodeAdoptingInitTests (parent-wiring and post-adoption mutability), the W3C XML conformance corpora, the Xalan XSLT gold-output corpus, the full suite, the WASM build, and an adversarial equivalence review. |
||
|---|---|---|
| .. | ||
| design | ||
| plans | ||
| rules | ||
| benchmarks.md | ||
| onboarding-antigravity.md | ||
| production-readiness.md | ||
| release-hurdles.md | ||
| roadmap.md | ||
| schema-validity-burndown.md | ||
| validation-coverage-registry.txt | ||
| validation-field-registry.txt | ||
| xsts-deviations.md | ||