Optimize AbstractCompositeRuntimeType storage 44/100144/4
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 17 Mar 2022 22:01:26 +0000 (23:01 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 17 Mar 2022 23:15:00 +0000 (00:15 +0100)
commit72648dcb3a85ca7c49ca492cb54acd198cc1e0c9
treed371bd06042190d08f26d96c0dda24f63d91f689
parent0ee55d1f9da11dd03ff05fc67d10cbcbfe63fd2c
Optimize AbstractCompositeRuntimeType storage

Storage on schema tree does not allow for duplicates. Rather than
allocating a full Map, let's use arrays and associated binary search.
This allows us to drop the storage requirements, especially for choices,
which would end up allocating an object to contain Map.values()
representation.

This results in O(log2(N)) lookups instead of O(1), plus some additional
code, but the lookups are one-off and so well worth the reduced
footprint. A further improvement is that we relax type safety down to
Object, which allows us to not allocate singleton arrays.

Change-Id: Ice6f07a7f853bd68c614a42eda6cc1d3fd2c184e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-generator/src/main/java/org/opendaylight/mdsal/binding/generator/impl/rt/AbstractCompositeRuntimeType.java
binding/mdsal-binding-generator/src/main/java/org/opendaylight/mdsal/binding/generator/impl/rt/DefaultChoiceRuntimeType.java
binding/mdsal-binding-runtime-api/src/main/java/org/opendaylight/mdsal/binding/runtime/api/ChoiceRuntimeType.java