Reuse child NodeIdentifier 90/21790/2
authorRobert Varga <rovarga@cisco.com>
Wed, 3 Jun 2015 12:46:18 +0000 (14:46 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 3 Jun 2015 17:58:10 +0000 (17:58 +0000)
We effectively create two YangInstanceIdentifiers for the same thing,
except for routes we end up creating a different instance of
NodeIdentifier, which forces a slower comparison. Reuse the same
identifier, lowring memory pressure and increasing performance slightly.

Change-Id: I80e8ffa89737476040727f45a8b90bd157527955
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 6416127e56a0fc0f2645823e082a4eaa39142a28)

bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/EffectiveRibInWriter.java

index 85b44407f93aee04d3347ad8f13bcd0759123819..4781768446f24df2fc92a913d58c51c8092a1a16 100644 (file)
@@ -144,14 +144,14 @@ final class EffectiveRibInWriter implements AutoCloseable {
                     break;
                 case SUBTREE_MODIFIED:
                 case WRITE:
-                    tx.put(LogicalDatastoreType.OPERATIONAL, tablePath.node(child.getIdentifier()), child.getDataAfter().get());
+                    final YangInstanceIdentifier childPath = tablePath.node(child.getIdentifier());
+                    tx.put(LogicalDatastoreType.OPERATIONAL, childPath, child.getDataAfter().get());
 
                     // Routes are special, as they may end up being filtered. The previous put conveniently
                     // ensured that we have them in at target, so a subsequent delete will not fail :)
                     if (TABLE_ROUTES.equals(child.getIdentifier())) {
-                        final YangInstanceIdentifier routesPath = tablePath.node(Routes.QNAME);
                         for (final DataTreeCandidateNode route : ribSupport.changedRoutes(child)) {
-                            processRoute(tx, ribSupport, policy, routesPath, route);
+                            processRoute(tx, ribSupport, policy, childPath, route);
                         }
                     }
                     break;