Use ImmutableMap for single namespaces 63/87163/3
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 27 Jan 2020 11:31:15 +0000 (12:31 +0100)
committerRobert Varga <nite@hq.sk>
Mon, 27 Jan 2020 12:49:29 +0000 (12:49 +0000)
commitd70b1fa5aed64c15ba079e131243c7eed2f8ba03
tree26b7e1c8b039e888143f72292af372fd058b13e2
parentc26a568163a9a2949780df2309b64a5ad423280b
Use ImmutableMap for single namespaces

It is extremely common for statement contexts to have exactly one
namespace (i.e. ChildSchemaNodeNamespace). Tracking that in a HashMap
is not very memory-efficient (nor performance-efficient), as we will
end up allocating all the HashMap internals.

Separate out the single-namespace case and use an ImmutableMap singleton
to hold the namespace -- which saves ~65MiB in a reference test case
accounding for ~6% of scratch memory used (~3% total used).

JIRA: YANGTOOLS-652
Change-Id: Ie2b1faeb4c966c20be0818d3b54aa7c8367f0c58
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/NamespaceStorageSupport.java