[antlr-interest] Is this Recognizer optimization valid?

Sander Mägi sander at aqris.com
Tue Oct 2 07:40:34 PDT 2001


null would give null pointer exception. The ASTpair's root and child
variables are still read for their content like returnAst = currentAst.root.

Sander

----- Original Message -----
From: "Ric Klaren" <klaren at cs.utwente.nl>
To: <antlr-interest at yahoogroups.com>
Cc: "Ryan Davis" <ryand at amazon.com>; "Terence Parr" <parrt at jguru.com>
Sent: Tuesday, October 02, 2001 4:33 PM
Subject: Re: [antlr-interest] Is this Recognizer optimization valid?


> Hi,
>
> 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.
>
> Cheers,
>
> Ric
> --
> -----+++++*****************************************************+++++++++--
-----
>     ---- 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/
>
>
>


 

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



More information about the antlr-interest mailing list