[antlr-interest] Is this Recognizer optimization valid?

Sander Mägi sander at aqris.com
Tue Oct 2 06:48:13 PDT 2001


Hi

I did some search and replace on my JavaRecognizer.java file (from java.g) to gain speed and memory - it seems to work in my tests.

Maybe someone can confirm that this optimization is indeed correct.

I defined a variable:
private static final ASTPair NULL_PAIR = new ASTPair();

And replaced all occurences of 'new ASTPair()' with '(inputState.guessing==0)?new ASTPair():NULL_PAIR;'

This makes garbage collector very happy and makes program a bit faster too.

br,
Sander Mägi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20011002/d5b263bd/attachment.html


More information about the antlr-interest mailing list