Optimize ArgumentContext parsing 82/87782/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 12 Feb 2020 22:10:25 +0000 (23:10 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 16 Feb 2020 09:51:13 +0000 (10:51 +0100)
commit2e80c8e4d29a622b258795344fc785c5d80aff5a
tree691f4419fb3b0fc0c54028efa34518c606d64e78
parent07b9c7a70faeed58acfa0876bef6a1849c404725
Optimize ArgumentContext parsing

Looking for strings is overly-pessimistic, as it forces allocation
of an intermediate list -- which we do not need, as we really want
to just invoke our method on appropriate methods.

Furthermore IDENTIFIER tokens are much more common than STRING, so
we want to make the decision for the correct codepath without any
bias -- and a switch statement does exactly that.

On top of that IDENTIFIER tokens do not need any further processing,
we just short-circuit to returning the token string.

JIRA: YANGTOOLS-1079
Change-Id: Ia1bf7e39d35b16b2e68f4f132cd14d60ce89492e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/ArgumentContextUtils.java