PureXML/Sources/Canonical
Mihaela Mihaljevic 33160ef775
perf(canonical): make the prefix rewrite and node-subset emit depth-safe (#355)
Two Canonical XML transforms still recursed one native frame per element level,
so a deeply-nested document overflowed the stack.

The C14N 2.0 sequential prefix rewrite walks the tree twice. Its assign pass
(which records one canonical prefix per namespace in document order) is now an
iterative pre-order walk; its rebuild pass is now a child-gathering accumulator
driven by an explicit work stack, threading the in-scope declarations and the
root flag down per element. The document-order prefix assignment and the
root-hoisted declarations are unchanged.

The node-subset serializer (`canonicalize(_:including:)`) now drives the same
deferred-close work stack as the main serializer, threading each element's
in-scope and rendered namespace context; an omitted element still passes its
declarations to descendants without rendering or a close tag.

The canonical bytes are unchanged: the C14N exclusive, 2.0, and node-subset
corpora pass (1794 tests). A 50000-deep document now rewrites and
subset-canonicalizes without crashing, guarded by `CanonicalDepthSafetyTests`.
Part of #350.
2026-06-27 17:08:37 +02:00
..
CanonicalEscaping.swift feat(canonical): C14N 1.0 spec-example vectors, three conformance fixes 2026-06-10 08:51:47 +02:00
Canonicalizer.swift perf(canonical): make the prefix rewrite and node-subset emit depth-safe (#355) 2026-06-27 17:08:37 +02:00
CanonicalNodeSubset.swift perf: make tree-to-tree transforms depth-safe (DTD defaults, canonicalization) (#352) 2026-06-26 19:27:37 +02:00
CanonicalOptions.swift feat(c14n): Canonical XML 1.1 (xml:base merging, no xml:id inheritance) 2026-06-09 17:59:35 +02:00
CanonicalPrefixRewrite.swift perf(canonical): make the prefix rewrite and node-subset emit depth-safe (#355) 2026-06-27 17:08:37 +02:00
CanonicalSelectedStep.swift perf(canonical): make the prefix rewrite and node-subset emit depth-safe (#355) 2026-06-27 17:08:37 +02:00
CanonicalStep.swift perf: make tree-to-tree transforms depth-safe (DTD defaults, canonicalization) (#352) 2026-06-26 19:27:37 +02:00
CanonicalURI.swift feat(c14n): Canonical XML 1.1 (xml:base merging, no xml:id inheritance) 2026-06-09 17:59:35 +02:00