Speed up PeerSpecificParserConstraintImpl 73/78373/6
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 3 Dec 2018 10:34:19 +0000 (11:34 +0100)
committerClaudio David Gasparini <claudio.gasparini@pantheon.tech>
Fri, 7 Dec 2018 15:16:58 +0000 (15:16 +0000)
commita86726e5e52d64a13882051e965f0498910ce941
tree43ad6fc8a925551ae3ef468940d6ccc05d151ffd
parent8f516139676a32aafdae06944ea8a0d9fcb42d12
Speed up PeerSpecificParserConstraintImpl

This improves design by taking advantage of ClassToInstanceMap,
which provides a type-safe getInstance() method. Furthermore we
recognize that the this class is used mostly for lookups of a few
classes, we use an ImmutableClassToInstanceMap updated concurrently
via a compare-and-set.

This yields significantly faster lookups for the common cases, where
the map is empty or has a single entry. In other cases the speed up
is still there, although not as pronounced.

Change-Id: I4da36e592e88cf22d5ad1654f126eec81660c98c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/pojo/PeerSpecificParserConstraintImpl.java