From 12aed3020757d7c08a0eaaf30e95ca810ce5c35a Mon Sep 17 00:00:00 2001 From: Davy Landman Date: Sat, 17 Jun 2023 22:44:26 +0200 Subject: [PATCH] Improve parser performance by removing old JDT/JIT tuning This change made the parser run between 8 and 12% faster --- src/org/rascalmpl/parser/gtd/stack/edge/EdgesSet.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/org/rascalmpl/parser/gtd/stack/edge/EdgesSet.java b/src/org/rascalmpl/parser/gtd/stack/edge/EdgesSet.java index 0a16717c404..b778f6677a3 100644 --- a/src/org/rascalmpl/parser/gtd/stack/edge/EdgesSet.java +++ b/src/org/rascalmpl/parser/gtd/stack/edge/EdgesSet.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.rascalmpl.parser.gtd.stack.edge; +import java.util.Arrays; + import org.rascalmpl.parser.gtd.result.AbstractContainerNode; import org.rascalmpl.parser.gtd.stack.AbstractStackNode; import org.rascalmpl.parser.gtd.util.IntegerMap; @@ -48,10 +50,9 @@ public EdgesSet(int initialSize){ } private void enlarge(){ - AbstractStackNode

[] oldEdges = edges; - edges = (AbstractStackNode

[]) new AbstractStackNode[size << 1]; - System.arraycopy(oldEdges, 0, edges, 0, size); + edges = Arrays.copyOf(edges, size << 1, edges.getClass()); } + public void add(AbstractStackNode

edge){ while(size >= edges.length){ // While instead of if to enable the JIT to eliminate the bounds check on the edges array