EventReader.next(), both initializers, and the Event alias are public (an internal typealias in a split file had been shadowing the public Parsing.Event); a new PureXMLPublicAPITests target compiles without testable import so facade gaps fail CI. The large-corpus benchmarks exposed document-order sorting as quadratic on flat fan-outs; the fix's first attempt was itself worse (an eager sibling table built per predicate evaluation), caught by sampling the live run, and replaced with a lazy table: single-node sets never touch order keys and a parent's table builds on its second lookup. XPath at 42 MB drops 27.1 s to 1.57 s (190x to 11.7x); at 210 MB PureXML completes in 9.4 s the query libxml2 refuses at its 10M node-set cap (#143 tracks our configurable budget). Benchmark harness: size series to 210 MB, CORPUS mode for real files (NASA, SwissProt measured), SAX stage, refusal-aware table, NULL-safe C driver. All conformance suites, Linux, and WASM verified. Closes #142.
29 lines
1.2 KiB
Swift
29 lines
1.2 KiB
Swift
/// The end-tag scanner, split from the reader body to keep it under the
|
|
/// length caps. Behavior is part of EventReader proper.
|
|
extension PureXML.Parsing.EventReader {
|
|
/// Public: this alias shadows the public Parsing.Event for the whole
|
|
/// type, so it must not narrow the public next() signature (#142).
|
|
public typealias Event = PureXML.Parsing.Event
|
|
typealias ParseError = PureXML.Parsing.ParseError
|
|
mutating func scanEndTag() throws -> Event {
|
|
let mark = reader.mark
|
|
reader.consume("</")
|
|
let name = try scanName()
|
|
reader.skipSpace()
|
|
guard reader.consume(">") else {
|
|
throw ParseError.unterminatedTag(reader.mark)
|
|
}
|
|
guard let top = open.last else {
|
|
throw ParseError.unexpectedEndTag(name: name.description, mark)
|
|
}
|
|
// Tag matching is lexical (the qualified-name text must match); the
|
|
// open name additionally carries its resolved namespace URI.
|
|
guard top.description == name.description else {
|
|
throw ParseError.mismatchedEndTag(expected: top.description, found: name.description, mark)
|
|
}
|
|
open.removeLast()
|
|
namespaces.leaveElement()
|
|
return .endElement(name: top)
|
|
}
|
|
}
|