From 4ea2421f854e0a672707bea082a53b847bcceae8 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 4 Sep 2019 13:34:38 +0200 Subject: [PATCH] Optimize BuilderTemplate string references AUGMENTATION_FIELD.toFirstUpper is a true constant, make sure we compute it only once. Also, in case of augmentable, the augmentable imported name is an invariant, hence precompute the string and use it multiple times in the template. Change-Id: I9607ac2e18e587118659545205323037db176fda Signed-off-by: Robert Varga (cherry picked from commit 55f2409e9afd9eb7b82213bdd9e710b4e206495a) --- .../binding/java/api/generator/BuilderTemplate.xtend | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/BuilderTemplate.xtend b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/BuilderTemplate.xtend index d689a475a7..b2ec1b51a0 100644 --- a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/BuilderTemplate.xtend +++ b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/BuilderTemplate.xtend @@ -43,6 +43,8 @@ class BuilderTemplate extends AbstractBuilderTemplate { */ public static val BUILDER = "Builder"; + static val AUGMENTATION_FIELD_UPPER = AUGMENTATION_FIELD.toFirstUpper + /** * Constructs new instance of this class. * @throws IllegalArgumentException if genType equals null @@ -320,9 +322,10 @@ class BuilderTemplate extends AbstractBuilderTemplate { «ENDFOR» «IF augmentType !== null» - public «type.name» add«AUGMENTATION_FIELD.toFirstUpper»(«Class.importedName» augmentationType, «augmentType.importedName» augmentationValue) { + «val augmentTypeRef = augmentType.importedName» + public «type.name» add«AUGMENTATION_FIELD_UPPER»(«Class.importedName» augmentationType, «augmentTypeRef» augmentationValue) { if (augmentationValue == null) { - return remove«AUGMENTATION_FIELD.toFirstUpper»(augmentationType); + return remove«AUGMENTATION_FIELD_UPPER»(augmentationType); } if (!(this.«AUGMENTATION_FIELD» instanceof «HashMap.importedName»)) { @@ -333,7 +336,7 @@ class BuilderTemplate extends AbstractBuilderTemplate { return this; } - public «type.name» remove«AUGMENTATION_FIELD.toFirstUpper»(«Class.importedName» augmentationType) { + public «type.name» remove«AUGMENTATION_FIELD_UPPER»(«Class.importedName» augmentationType) { if (this.«AUGMENTATION_FIELD» instanceof «HashMap.importedName») { this.«AUGMENTATION_FIELD».remove(augmentationType); } -- 2.36.6