forked from jasder/antlr
Make C++ Parser::exitRule() non-virtual
Parser::exitRule() in the C++ runtime is a virtual function which is not reimplemented anywhere. OTOH, it is invoked during the execution of every rule, which can cause a noticeable performance hit. This commit removes its virtual qualifier. It should make a difference particularly for large grammars, because the number of rules corresponds to the number of the Parser object's virtual functions, and, consequently, its vtable lookup time. Tested with a VHDL grammar of 436 rules, where it brings down parsing time from 75 to 44 seconds on unoptimized compilation, i.e. a 40% speed gain. Still a lot slower than an equivalent java parser, though, which takes 2.64 seconds for the same input.
This commit is contained in:
parent
2634246b07
commit
4e3c5ddffb
|
@ -272,7 +272,7 @@ namespace antlr4 {
|
||||||
/// <seealso cref="#_ctx"/> get the current context.
|
/// <seealso cref="#_ctx"/> get the current context.
|
||||||
virtual void enterRule(ParserRuleContext *localctx, size_t state, size_t ruleIndex);
|
virtual void enterRule(ParserRuleContext *localctx, size_t state, size_t ruleIndex);
|
||||||
|
|
||||||
virtual void exitRule();
|
void exitRule();
|
||||||
|
|
||||||
virtual void enterOuterAlt(ParserRuleContext *localctx, size_t altNum);
|
virtual void enterOuterAlt(ParserRuleContext *localctx, size_t altNum);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue