Optimize AbstractTypeGenerator.listKeys() 22/85822/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 18 Nov 2019 11:36:45 +0000 (12:36 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 18 Nov 2019 14:13:02 +0000 (15:13 +0100)
commitefe9042ecb51521850d9b90f4d8460a35c9bd9ea
treeebd0b8b08a9af6c6bfe2a1487995de1b891e1d52
parent6087dda3aa2e148c5046fb2d8e7b0f75a5eee844
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>
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/AbstractTypeGenerator.java