Skip to content

Commit

Permalink
Removed redundant character creation caching
Browse files Browse the repository at this point in the history
  • Loading branch information
PieterOlivier committed Dec 7, 2024
1 parent eda3949 commit 67d541f
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions src/org/rascalmpl/parser/gtd/result/out/CharNodeFlattener.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
/**
* A converter for character result nodes.
*/
@SuppressWarnings("unchecked")
public class CharNodeFlattener<T, P>{
private final T[] cache = (T[]) new Object[128];

public CharNodeFlattener(){
super();
}
Expand All @@ -28,17 +25,6 @@ public CharNodeFlattener(){
* Converts the given character result node to the UPTR format.
*/
public T convertToUPTR(INodeConstructorFactory<T, P> nodeConstructorFactory, CharNode node){
int charNumber = node.getCharacter();

// Cache 7-bit ASCII character results.
if(charNumber < 128){
T result = cache[charNumber];
if(result != null) return result;

result = nodeConstructorFactory.createCharNode(charNumber);
cache[charNumber] = result;
}

return nodeConstructorFactory.createCharNode(charNumber);
return nodeConstructorFactory.createCharNode(node.getCharacter());
}
}

0 comments on commit 67d541f

Please sign in to comment.