Optimize LinkstateGraphBuilder.getVertexId() 31/96931/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 20 Jul 2021 08:50:31 +0000 (10:50 +0200)
committerRobert Varga <nite@hq.sk>
Tue, 20 Jul 2021 10:06:54 +0000 (10:06 +0000)
Eliminate the use of a temporary Long, reducing the number of type
conversions we perform.

Change-Id: Iff20437ae066ba4618945c7c0230e5fd042d1f03
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bgp/topology-provider/src/main/java/org/opendaylight/bgpcep/bgp/topology/provider/LinkstateGraphBuilder.java

index b4bdccfca52db6ad59efd0e7c7c12ec44a5d534e..1677ea980272d8acbdc0b3745bbc59be5f14a27f 100644 (file)
@@ -626,19 +626,19 @@ public class LinkstateGraphBuilder extends AbstractTopologyBuilder<LinkstateRout
      * @return Vertex in the Connected Graph that corresponds to this Router ID. Vertex is created if not found.
      */
     private static Uint64 getVertexId(final CRouterIdentifier routerID) {
-        Long rid = 0L;
+        Uint64 rid = Uint64.ZERO;
 
         if (routerID instanceof IsisNodeCase) {
-            byte[] isoId = ((IsisNodeCase) routerID).getIsisNode().getIsoSystemId().getValue();
-            final byte[] convert =  {0, 0, isoId[0], isoId[1], isoId[2], isoId[3], isoId[4], isoId[5]};
-            rid = ByteBuffer.wrap(convert).getLong();
+            final byte[] isoId = ((IsisNodeCase) routerID).getIsisNode().getIsoSystemId().getValue();
+            final byte[] convert = {0, 0, isoId[0], isoId[1], isoId[2], isoId[3], isoId[4], isoId[5]};
+            rid = Uint64.fromLongBits(ByteBuffer.wrap(convert).getLong());
         }
         if (routerID instanceof OspfNodeCase) {
-            rid = ((OspfNodeCase) routerID).getOspfNode().getOspfRouterId().longValue();
+            rid = ((OspfNodeCase) routerID).getOspfNode().getOspfRouterId().toUint64();
         }
 
         LOG.debug("Get Vertex Identifier {}", rid);
-        return Uint64.valueOf(rid);
+        return rid;
     }
 
     private static DecimalBandwidth bandwithToDecimalBandwidth(final Bandwidth bw) {