PureXML/Sources/Emitting
Mihaela Mihaljevic 0abbe348d7
perf(emitting): skip escaping rebuild for values that need no escaping (#279)
The serializer's escaping functions rebuilt every text, attribute, comment,
and processing-instruction value character by character, even when the value
contained nothing to escape, which is the common case. Each now scans the
value's UTF-8 bytes for the bytes it would escape (the markup characters, the
active attribute quote, the whitespace characters, a comment hyphen, a PI
question mark, and any non-ASCII byte in ASCII-only mode) and returns the
value unchanged when none is present, taking the original character path only
when something must be escaped.

Measured serialize roughly halved, ~5.5x to ~2.7x slower than libxml2 on the
20k-item generated corpus, with byte-identical output. EscapingFastPathTests
pins both the unchanged fast path and the escaped slow path for each function,
and the Apache Xalan XSLT gold-output corpus (a serialize-heavy differential)
stays green. No output changed.
2026-06-25 00:56:52 +02:00
..
Escaping.swift perf(emitting): skip escaping rebuild for values that need no escaping (#279) 2026-06-25 00:56:52 +02:00
Options.swift feat(emitting): textEscaping round-trip option to preserve carriage returns (#91) 2026-06-09 03:48:20 +02:00
Serializer.swift fix(emit): split ?> in processing-instruction data with a space (#262) 2026-06-24 03:14:01 +02:00
Writer.swift fix(emit): split ?> in processing-instruction data with a space (#262) 2026-06-24 03:14:01 +02:00