Skip to content

Commit

Permalink
Improve parser performance by removing old JDT/JIT tuning
Browse files Browse the repository at this point in the history
This change made the parser run between 8 and 12% faster
  • Loading branch information
DavyLandman committed Jun 17, 2023
1 parent f2e37a0 commit b3c36ca
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/org/rascalmpl/parser/gtd/stack/edge/EdgesSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -48,13 +50,11 @@ public EdgesSet(int initialSize){
}

private void enlarge(){
AbstractStackNode<P>[] oldEdges = edges;
edges = (AbstractStackNode<P>[]) new AbstractStackNode[size << 1];
System.arraycopy(oldEdges, 0, edges, 0, size);
edges = Arrays.copyOf(edges, size << 1, edges.getClass());
}

public void add(AbstractStackNode<P> edge){
while(size >= edges.length){ // While instead of if to enable the JIT to eliminate the bounds check on the edges array
if (size >= edges.length) {
enlarge();
}

Expand Down

0 comments on commit b3c36ca

Please sign in to comment.