Optimize ArgumentContext parsing 89/87689/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 12 Feb 2020 22:10:25 +0000 (23:10 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 13 Feb 2020 22:43:31 +0000 (23:43 +0100)
commitd6ef64c5dccdf236cd4577cdb845602c6d5d5923
tree906d14dcc5817e18f3c349e7a162ad733ce5f7a2
parentc052ffbc0fe3ca67d3853ddbae49b2a8a5d96d58
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