parseTree ran TreeNode(parse(...)), which allocates two full trees: the parser builds an immutable value Node tree, then TreeNode.init(_:) walks it to build the mutable reference tree. The parsed tree is the deliverable, so building the value tree first is pure overhead. Parser.buildTree is the direct counterpart to build: the same iterative event loop with the same element stack and the same well-formedness guards (an unmatched end tag throws unexpectedEndOfInput; a document with no element throws emptyDocument), but it accumulates TreeNode children per frame and adopts them when an element closes, so the tree is allocated once. The produced tree is identical: same kinds, names, attributes, values, child order, and parent links. Measured parse ~8% faster on the 20k-item generated corpus via a same-state A/B (6.1x to ~5.5x slower than libxml2). Verified by ParseTreeDirectBuildTests (a structural differential against the convert-from-Node path, plus throw-parity and a serialized round-trip), the full suite and the W3C XML conformance, RELAX NG, and Xalan corpora (which all build trees through parseTree), the WASM build, and an adversarial equivalence review. |
||
|---|---|---|
| .. | ||
| 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 | ||
| 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 | ||