[antlr-interest] Performance and LA(int)

Micheal J open.zone at virgin.net
Thu Feb 24 14:32:05 PST 2005


> Paul J. Lucas wrote:
> > 	In recent profiling, the ANTLR lexer method LA(int) is called a
> > 	*lot*.  Why does the ANTLR-generated code repeatedly call it?
> > 	Why not copy the current value into a local variable?
> 
> Tried to implement this a while ago but it was not easy to do 
> with the 
> current codegenerator should probably stil be some posts 
> about it in the 
> archive. It was probably due to not being able to get 
> declarations for 
> the temporary vars in the right places.

Yep. Tried that and wasn't getting anywhere fast too. For C#, LA1/LA2 are
cached in dedicated member variables of the CharScanner class. Still gives a
substantial speedup.

Micheal



More information about the antlr-interest mailing list