BUG-1228: Optimize AbstractForwardedDataBroker a bit
Profiling OFP with datastore backend has revealed that we spend about 9%
of CPU in AbstractForwardedDataBroker$1.compare(). This turns out to be
a comparator, which compares two YangInstanceIdentifiers by their path
length -- and to do that it iterates fully through both of them.
We perform three optimizations:
- make the comparator itself shareable, so we do not instantiate it
(6000 during the profiling run)
- make the .sortedEntries() smart about empty maps
- teach the comparator to abort iteration as soon as the result is
known
At the same time we import YangInstanceIdentifier, making the code a bit
more readable.
Change-Id: I38d3629ab33dac9e2e29b092e3a89d0821d09b07
Signed-off-by: Robert Varga <rovarga@cisco.com>