From a5b057d9484bd1cf15c90da945846d58cfcb5ae6 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Sun, 9 Aug 2026 11:01:05 +0000 Subject: [PATCH 1/2] perf(printer): index merge-monikers lookups with keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "merge-monikers.xsl" asked the same question from every node it visited — "which references in this formation name this binding?" — and answered it with a "$owner//o[...]" scan, so a document of N nodes walked its own subtree N times. On a 2000-node XMIR that is already over 10 seconds, and the cost grows quadratically from there. The four lookups are now backed by "xsl:key" indexes: references by owning formation and resolved name, applied references by owning formation and receiver name, and eligible bindings by owner-and-name and by name alone. Keys hand their nodes back in document order, so "the first hosting reference" still means what it meant before. The "ξ." prefix is hoisted into a global variable too, since Saxon rebuilds "concat($eo:xi, '.')" at every call rather than folding it. Output is unchanged: the sheet emits byte-identical XML on every fixture and synthetic input tested, and all 334 "eo-printer" tests pass. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01SgyCtxMVnZq4qnDXedksSu --- .../eolang/printer/print/merge-monikers.xsl | 63 +++++++++++++++---- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/eo-printer/src/main/resources/org/eolang/printer/print/merge-monikers.xsl b/eo-printer/src/main/resources/org/eolang/printer/print/merge-monikers.xsl index 8ba2c7814f7..33d2e69a048 100644 --- a/eo-printer/src/main/resources/org/eolang/printer/print/merge-monikers.xsl +++ b/eo-printer/src/main/resources/org/eolang/printer/print/merge-monikers.xsl @@ -37,6 +37,45 @@ + + + + + + + + + + - - + + - - + + - + @@ -327,7 +366,7 @@ --> - + From effa12358a5b4ac3a1a6d2399d5471eab28464a3 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Sun, 9 Aug 2026 11:29:17 +0000 Subject: [PATCH 2/2] style(printer): rename the ancestor range variable to $scope "typos" reads the XPath range variable "$anc" as a misspelling of "and" and fails the build on all four of its occurrences. "eo:shadowed" already walks the ancestor formations under the name "$scope", so the two kept- reference lookups now spell it the same way. Purely a rename: output stays byte-identical on every real "eo-runtime" file and synthetic input checked, and all 334 "eo-printer" tests pass. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01SgyCtxMVnZq4qnDXedksSu --- .../resources/org/eolang/printer/print/merge-monikers.xsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eo-printer/src/main/resources/org/eolang/printer/print/merge-monikers.xsl b/eo-printer/src/main/resources/org/eolang/printer/print/merge-monikers.xsl index 33d2e69a048..43868ab2720 100644 --- a/eo-printer/src/main/resources/org/eolang/printer/print/merge-monikers.xsl +++ b/eo-printer/src/main/resources/org/eolang/printer/print/merge-monikers.xsl @@ -304,7 +304,7 @@ --> - + @@ -366,7 +366,7 @@ --> - +