BUG-582: optimize InstanceIdentifier.firstIdentifierOf() 65/7765/2
authorRobert Varga <rovarga@cisco.com>
Thu, 5 Jun 2014 21:46:21 +0000 (23:46 +0200)
committerRobert Varga <rovarga@cisco.com>
Fri, 6 Jun 2014 08:45:19 +0000 (10:45 +0200)
commit48d5dd55abc2365d8cbc46abda50dc9a40cf16d5
tree64d9d0e50da968c5865546b0d71622a7b869b9ba
parentf74f1535435f491f23f75001924a8e8a998c9b1f
BUG-582: optimize InstanceIdentifier.firstIdentifierOf()

Performance tracing of OpenFlow components found that we are spending
cycles copying arguments in create() when called from firstIdentifierOf().
This does not make sense, as we know the argument list is immutable in
this code path.

As it turns out, the copy guard in create() is not sufficient to prevent
the copy, as the Iterables.limit() instantiates a FluentIterable, not an
ImmutableCollection.

This patch elides the copy by splitting the non-copy part of logic of
create() to a private method, internalCreate(). firstIdentifierOf()
calls this method directly, while create() calls it after potentially
creating a copy.

Change-Id: I5c3dbb5c6b5e26d30a0bb407822f1d40fcc898f5
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java