[antlr-interest] Is this Recognizer optimization valid?

Ric Klaren klaren at cs.utwente.nl
Tue Oct 2 07:33:20 PDT 2001


On Tue, Oct 02, 2001 at 03:48:13PM +0200, Sander Mägi wrote:
> 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;'

During guessing no tree construction is done, so it's probably even safe to
say (inputState.guessing==0)?new ASTPair():null;

Very cheap optimization btw =) Nice work.


    ---- Ric Klaren ----- klaren at cs.utwente.nl ----- +31 53 4893722  ----
     Human beings, who are almost unique in having the ability to learn
   from the experience of others, are also remarkable for their apparent
         disinclination to do so. --- Douglas Adams, Last Chance to See


Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

More information about the antlr-interest mailing list