Optimize array checks 82/84382/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 4 Sep 2019 14:24:01 +0000 (16:24 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 13 Sep 2019 14:10:35 +0000 (16:10 +0200)
Rather than bouncing through .importedName().contains("[]"), we
can make this check through .name().endsWith("[]"), which prevents
a round-trip to import mechanics and is potentially faster.

Change-Id: I4a939333c294ffa94ac1c013a8e3cee466e32cb9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 35400adb8f5c7db3320fdf6fbcbadf377569c2e0)

binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/BaseTemplate.xtend
binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/ClassTemplate.xtend
binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/UnionTemplate.xtend

index 44bb515533056ca9bcc5b1700279b8375ec453fe..58ccbd45071cb981cc3c1d0b1fe90a76039cac6f 100644 (file)
@@ -109,7 +109,7 @@ abstract class BaseTemplate extends JavaFileTemplate {
         '''
             public «field.returnType.importedName» «field.getterMethodName»() {
                 «val fieldName = field.fieldName»
-                «IF field.returnType.importedName.contains("[]")»
+                «IF field.returnType.name.endsWith("[]")»
                 return «fieldName» == null ? null : «fieldName».clone();
                 «ELSE»
                 return «fieldName»;
index 2465ce21df879ce4368d60c2fc0b9a8a936763f3..c34953fd052f2fdab71844a159e2d4d5b3edc701 100644 (file)
@@ -228,7 +228,7 @@ class ClassTemplate extends BaseTemplate {
 
         «FOR p : properties»
             «val fieldName = p.fieldName»
-            «IF p.returnType.importedName.contains("[]")»
+            «IF p.returnType.name.endsWith("[]")»
                 «IF genTO.typedef && allProperties.size == 1 && allProperties.get(0).name.equals("value")»
                 this.«fieldName» = «fieldName».clone();
                 «ELSE»
index 81b4db14537934400c80ceed2c2ebc471c2ea741..9808196a298ebfc278cdf795a305dd625b03326d 100644 (file)
@@ -173,7 +173,7 @@ class UnionTemplate extends ClassTemplate {
             «ENDIF»
             «FOR p : properties»
                 «val fieldName = p.fieldName»
-                «IF p.returnType.importedName.contains("[]")»
+                «IF p.returnType.name.endsWith("[]")»
                 this.«fieldName» = source.«fieldName» == null ? null : source.«fieldName».clone();
                 «ELSE»
                 this.«fieldName» = source.«fieldName»;