From b239fe2b962fdf494c9fb60066e406985cf1ee24 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 12 Aug 2026 13:32:46 +0000 Subject: [PATCH] fix(transpile): #6664 serialize XMIR into one string The "serialize" template in classes.xsl wrote the XMIR of an object into "" piece by piece - one instruction per indent, per angle bracket, per name and five per attribute. Since jcabi-xml runs every stylesheet DOM to DOM, each of those pieces became a separate DOM text node, so a single "" of a large eo-runtime object ended up holding tens of thousands of them. Building those nodes, and then reading them back through a DOM that has to merge adjacent text to answer "text()", cost far more than the concatenation itself: the pass alone was two fifths of the whole transpile train, and xsline warned "XSL 'classes' took 4s". It is now an "xsl:function" returning one string, written with one "xsl:value-of", so "" holds exactly one text node. The recursive call sits inside the enclosing "concat", which copies a subtree's string once per level of depth above it - measurably cheaper than returning a sequence of pieces and joining them at the end. Over all 170 sources of eo-runtime/src/main/eo, the pass drops from 21.5s to 1.0s and the whole nine-stylesheet train from 56.9s to 34.4s (the train gains more than the pass saves, because the downstream stylesheets no longer walk those adjacent text nodes). The output is byte-identical, both of this pass and of the train that ends in the generated Java. The class-matching pattern loses its redundant second "eo:atom" call at the same time: "not(A) or (A and B)" is "not(A) or B". Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01GevVXivd1KDNnCHqKW9rua --- .../org/eolang/maven/transpile/classes.xsl | 83 +++++++++---------- 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/eo-maven-plugin/src/main/resources/org/eolang/maven/transpile/classes.xsl b/eo-maven-plugin/src/main/resources/org/eolang/maven/transpile/classes.xsl index 1be67aecd67..8fe7e35f005 100644 --- a/eo-maven-plugin/src/main/resources/org/eolang/maven/transpile/classes.xsl +++ b/eo-maven-plugin/src/main/resources/org/eolang/maven/transpile/classes.xsl @@ -3,47 +3,47 @@ * SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com * SPDX-License-Identifier: MIT --> - + - - - - - - < - - - - - =" - - " - - - - / - - > - - - - - - - - - - - - - - </ - - > - - - + + + + + + + + + + + + + + @@ -67,10 +67,7 @@ - - - - +