Skip to content

Commit

Permalink
Merge pull request #2095 from usethesource/remove-redundant-character…
Browse files Browse the repository at this point in the history
…-caching

Removed redundant character creation caching
  • Loading branch information
jurgenvinju authored Dec 8, 2024
2 parents 3329554 + 67d541f commit 337210f
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 337210f

Please sign in to comment.