PureXML/Sources/Parsing
Mihaela Mihaljevic 3405c9709d
perf(parsing): resolve namespaces in O(1), making parse linear in depth (#346)
Each open element resolved its name and attributes by looking up namespace
bindings through NamespaceContext.lookup, which walked a stack of scopes as
deep as the document. With one lookup per element over an O(depth) stack,
parsing a deeply-nested document was O(depth^2): a 40000-deep document took
~39s.

The context now maintains the current in-scope bindings incrementally: a
single prefix-to-URI map, plus a per-element undo list recording the
bindings each element overwrote so closing it restores the enclosing state.
A lookup is O(1) and entering/leaving an element is O(its xmlns
declarations), so parsing is O(n). The same document now parses in ~0.2s.

Namespace semantics are unchanged: the nearest in-scope binding still wins,
an empty default binding still undeclares, and 81 namespace tests plus the
full suite (1784) pass. Closes #345.
2026-06-26 17:44:27 +02:00
..
Big5Decoder.swift
Big5Table1.swift
Big5Table2.swift
Big5Table3.swift
Big5Table4.swift
Big5Table5.swift
Big5Table6.swift
Big5Table.swift
ByteDecoder.swift
ByteEncoder.swift
ByteStorage.swift
CharacterClassification.swift
CJKByteEncoder.swift
Diagnostic.swift
DoctypeScanner.swift
DoctypeScannerConditional.swift
DoctypeScannerEntities.swift
DoctypeScannerStrict.swift
DocumentType.swift
DTDAttListGrammar.swift
DTDContentModelGrammar.swift
EntityDecoder.swift
EntityReplacementGrammar.swift
EntityResolver.swift
EUCJPDecoder.swift
EUCKRDecoder.swift
EUCKRTable1.swift
EUCKRTable2.swift
EUCKRTable3.swift
EUCKRTable4.swift
EUCKRTable5.swift
EUCKRTable6.swift
EUCTWDecoder.swift
EUCTWPlane11.swift
EUCTWPlane12.swift
EUCTWPlane13.swift
EUCTWPlane21.swift
EUCTWPlane22.swift
EUCTWPlane23.swift
EUCTWTable.swift
Event.swift
EventReader.swift
EventReaderAttributes.swift
EventReaderContent.swift
EventReaderEndTag.swift
EventReaderRecovery.swift
EventReaderValidity.swift
ExternalID.swift
GB18030Decoder.swift
GB18030Ranges.swift
GBKDecoder.swift
GBKTable1.swift
GBKTable2.swift
GBKTable3.swift
GBKTable4.swift
GBKTable5.swift
GBKTable6.swift
InputEncoding.swift
ISO2022JPDecoder.swift
JIS0208Table1.swift
JIS0208Table2.swift
JIS0208Table3.swift
JIS0212Table1.swift
JIS0212Table2.swift
Limits.swift
Mark.swift
NamespaceContext.swift perf(parsing): resolve namespaces in O(1), making parse linear in depth (#346) 2026-06-26 17:44:27 +02:00
ParsedDocument.swift
ParseError.swift
Parser.swift
ParserTreeBuild.swift
PseudoAttributeScanner.swift
PushAsync.swift
PushParser.swift
PushScanner.swift
Reader.swift
ReaderByteRuns.swift
ReadResult.swift
SAXHandler.swift
ShiftJISDecoder.swift
SingleByteEncodings.swift
SingleByteTables.swift
SourceRange.swift
StreamingDecoder.swift
StreamingDecoderEUCTW.swift
StreamingDecoderISO2022JP.swift
TextReader.swift
UnparsedEntity.swift
ValidityFinding.swift
XMLCharacter.swift
XMLDeclaration.swift