Skip to content

Commit

Permalink
feat(objectionary#834): speed up vars-float-down.xsl a bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Nov 11, 2024
1 parent 76c7f99 commit 5be4501
Show file tree
Hide file tree
Showing 6 changed files with 27,274 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/it/jna/invoker.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
# Just to compare, the 'short' path takes 13 seconds to run, while the 'full' path
# takes 31 minutes.
invoker.goals=clean verify -e -B
invoker.profiles=short
invoker.profiles=full
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private static XML unroll(final XML parsed) {
).back()
),
CanonicalXmir.class,
20
5
)
).pass(parsed);
}
Expand Down
8 changes: 7 additions & 1 deletion src/main/resources/org/eolang/parser/vars-float-down.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ SOFTWARE.
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="o[@ref and @ref!='' and not(ancestor::o[@ref])]">
<xsl:template match="o[@ref]">
<xsl:apply-templates select="." mode="non-empty-ref"/>
</xsl:template>
<xsl:template match="o[@ref!='']" mode="non-empty-ref">
<xsl:apply-templates select="." mode="without-top-ref"/>
</xsl:template>
<xsl:template match="o[not(ancestor::o[@ref])]" mode="without-top-ref">
<xsl:variable name="reference" select="@ref"/>
<xsl:variable name="found" select="key('o-by-line', $reference)"/>
<xsl:element name="o">
Expand Down
28 changes: 28 additions & 0 deletions src/test/java/org/eolang/jeo/representation/CanonicalXmirTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
package org.eolang.jeo.representation;

import com.jcabi.matchers.XhtmlMatchers;
import com.jcabi.xml.XML;
import com.jcabi.xml.XMLDocument;
import java.util.Collections;
import org.cactoos.io.ResourceOf;
import org.eolang.jeo.representation.bytecode.BytecodeClass;
import org.eolang.jeo.representation.bytecode.BytecodeClassProperties;
import org.eolang.jeo.representation.bytecode.BytecodeMethod;
Expand Down Expand Up @@ -124,4 +126,30 @@ void unrollsSequenceOfValuesCorrectly() {
)
);
}

@Test
void transfomsBigFile() throws Exception {
final String name = "Union.xmir";

final long start = System.currentTimeMillis();
final XML actual = new CanonicalXmir(
new XMLDocument(
new ResourceOf(String.format("xmir/unphi/%s", name)).stream()
)
).plain();
final long end = System.currentTimeMillis();
System.out.printf(
"CanonicalXmirTest.transfomsBigFile: %s: %d ms\n",
name,
end - start
);
final XML expected = new XMLDocument(
new ResourceOf(String.format("xmir/unroll/%s", name)).stream());
MatcherAssert.assertThat(
"The XMIR should be transformed correctly",
actual,
Matchers.equalTo(expected)
);

}
}
Loading

0 comments on commit 5be4501

Please sign in to comment.