Optimize ArgumentContext parsing 53/87653/5
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 12 Feb 2020 22:10:25 +0000 (23:10 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 12 Feb 2020 23:11:02 +0000 (00:11 +0100)
commit195338a3a4ddd4dae520aa64fb91f5e144bd94d9
tree5696a2ccab44985cffcaf6b6ba355ff1ea1eeb94
parenta28809d772346e828c2f50b018835180812ab2d6
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