Reuse child NodeIdentifier 58/21758/1
authorRobert Varga <rovarga@cisco.com>
Wed, 3 Jun 2015 12:46:18 +0000 (14:46 +0200)
committerRobert Varga <rovarga@cisco.com>
Wed, 3 Jun 2015 12:46:18 +0000 (14:46 +0200)
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>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/EffectiveRibInWriter.java

index 161f8ffdd18385b568a35309ea647657f4b7a8bd..5d4206977a374013e8c0e3acc5c11267d497ba70 100644 (file)
@@ -150,14 +150,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;