The lookahead buffer consumed from the front with Array.removeFirst() and re-injected entity replacement text with insert(at: 0), both O(buffer), so a single large entity (or a long content run pushed back by reference inclusion) was consumed in O(n^2). The buffer now advances a head index (front-consume O(1)) and re-injection reuses the freed prefix space, making a single large expansion linear. An 800k-character internal text entity drops from quadratic time to about 0.6 s. Same characters, same limits; 1775 tests unchanged. Found by adversarial robustness probing. |
||
|---|---|---|
| .. | ||
| Canonical | ||
| Catalog | ||
| Emitting | ||
| HTML | ||
| Model | ||
| Parsing | ||
| Pattern | ||
| Regex | ||
| Schema | ||
| Stream | ||
| Validation | ||
| XInclude | ||
| XPath | ||
| XPointer | ||
| XSLT | ||
| API.swift | ||
| Lint.swift | ||
| PureXML.swift | ||
| QuickFix.swift | ||