Optimize AbstractTypeGenerator.listKeys() 51/85851/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 18 Nov 2019 11:36:45 +0000 (12:36 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 19 Nov 2019 13:07:51 +0000 (14:07 +0100)
commitaf44ac5c13bbfe78d2bb0a107a4ed83d1b907fcc
tree22745540c299f1eb5a0b20ff286f6c34d2cc3e53
parentf8e4a9ed5420742dbfb1c29be2dc5de63411547c
Optimize AbstractTypeGenerator.listKeys()

In case of an empty key definition we end up allocating
short-lived empty ArrayLists, which is not efficient. Also lists
typically have a few elements, so we end up over-allocating them.

This fixes both cases, by checking the definition first and
returning an empty list in case the definition is empty, as well
as properly allocating efficient implementation where needed.

Change-Id: I99e8843abf6040654fab96052352cbfb29590ecf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit efe9042ecb51521850d9b90f4d8460a35c9bd9ea)
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/AbstractTypeGenerator.java