A long <xs:complexType> simpleContent extension chain (T0 extends T1 extends T2 ...) is flat in the document, so each of the N complex types re-walked its whole base chain to resolve the simple type its simpleContent derives from (an O(n^3) compile; a 400-link chain took ~23s). The resolved simple type is now memoized by complex-type name (SimpleContentMemo, a reference type surviving the value-type context copies, mirroring GroupParticleMemo); the same chain compiles in ~1.2s, and past the 512 expansion-depth bound it is rejected with a located error as before. Behaviour-preserving (an acyclic resolution is intrinsic to the name; a derivation cycle is rejected elsewhere), verified conformance-neutral over the full W3C XSTS corpus, the determinism differential, and the full suite. The attribute flattening along the chain is inherently quadratic in the bounded length and is tracked.
14 lines
844 B
Swift
14 lines
844 B
Swift
extension PureXML.Schema {
|
|
/// Memoizes the resolved simple type of a complex type's `simpleContent`, keyed by the
|
|
/// complex type's name, during one compile. A `simpleContent` derivation chain (`T0`
|
|
/// extends `T1` extends `T2`, and so on) is flat in the document, so without this each
|
|
/// of the N types re-walks its whole base chain while being compiled, an O(n^3) compile
|
|
/// (a 400-link chain took ~23 s); sharing the resolution makes it linear. A reference
|
|
/// type so it survives the value-type ``XSDContext`` copies (`scoped`/`visiting`); one
|
|
/// instance per compile. An acyclic resolution is intrinsic to the name (a derivation
|
|
/// cycle is rejected elsewhere), so the name is a sufficient key.
|
|
final class SimpleContentMemo {
|
|
var store: [String: PureXML.Schema.SimpleType] = [:]
|
|
}
|
|
}
|