Further optimize YANG statement parsing 02/92102/1
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 22 Aug 2020 20:26:56 +0000 (22:26 +0200)
committerRobert Varga <nite@hq.sk>
Sat, 22 Aug 2020 21:10:01 +0000 (21:10 +0000)
commit18f15f5c3ffcb717fc3ae384f327c4702863368b
treed2da98c885d5c1ff624347a09334f91ccf042355
parentbaa54330b75a1ed354a76f04bd3515f55d646d01
Further optimize YANG statement parsing

Recursive definition of stringPart can easily end up with a large
number of retained objects -- i.e. we get StringPartContext for
each concatenation, with potentially small lists of three tokens.

Furthermore each unquotedString has ends up being typically defined
by a UnquotedStringContext containing a single StringPartContext,
which is clearly wasteful.

The grammar we are looking at is not that complex, hence we can
rewrite it without relying on recursion -- thus improving memory
footprint.

JIRA: YANGTOOLS-1089
Change-Id: I18eb1305d3e024d530552ac5cea0b5a928da0048
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0ca5c81f163ed5a56d42cd8d68302654a9bb8918)
yang/yang-parser-antlr/src/main/antlr4/org/opendaylight/yangtools/yang/parser/antlr/YangStatementParser.g4