Mdsalhelper toBuilder performance issue 70/89070/1
authorSmokowski, Kevin (ks6305) <kevin.smokowski@att.com>
Fri, 31 May 2019 18:58:41 +0000 (18:58 +0000)
committerSmokowski, Kevin (ks6305) <kevin.smokowski@att.com>
Fri, 31 May 2019 18:58:41 +0000 (18:58 +0000)
Mdsalhelper toBuilder performance issue, no impact

Change-Id: I2788352b0f25f970380f15653008026f8a12a233
Issue-ID: CCSDK-1374
Signed-off-by: Smokowski, Kevin (ks6305) <kevin.smokowski@att.com>
sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java

index 4d17f87..0300236 100755 (executable)
@@ -401,7 +401,7 @@ public class MdsalHelper {
 
         LOG.trace("Saving properties to List<" + elemType.getName() + ">  from " + pfx);
 
-        if (props.contains(pfx + "_length")) {
+        if (props.containsKey(pfx + "_length")) {
             try {
                 int listLength = Integer.parseInt(props.getProperty(pfx + "_length"));
 
@@ -413,18 +413,19 @@ public class MdsalHelper {
             }
         }
 
+        String arrayKey = pfx + "[";
+        int arrayKeyLength = arrayKey.length();
         if (maxIdx == -1) {
             // Figure out array size
             for (Object pNameObj : props.keySet()) {
                 String key = (String) pNameObj;
 
-                if (key.startsWith(pfx + "[")) {
-                    String idxStr = key.substring(pfx.length() + 1);
+                if (key.startsWith(arrayKey)) {
+                    String idxStr = key.substring(arrayKeyLength);
                     int endloc = idxStr.indexOf("]");
                     if (endloc != -1) {
                         idxStr = idxStr.substring(0, endloc);
                     }
-
                     try {
                         int curIdx = Integer.parseInt(idxStr);
                         if (curIdx > maxIdx) {