Further optimize YANG statement parsing 39/92239/1
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 22 Aug 2020 20:26:56 +0000 (22:26 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 22 Aug 2020 20:31:08 +0000 (22:31 +0200)
commit0ca5c81f163ed5a56d42cd8d68302654a9bb8918
treeceb212654ffcdbe80c90114716b48e088ed4c146
parentf94e869efd16ca11f608c4d41888b3e5e1fd80d0
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>
yang/yang-parser-antlr/src/main/antlr4/org/opendaylight/yangtools/yang/parser/antlr/YangStatementParser.g4