Share pre-generated non-verbose string 15/67015/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 8 Jan 2018 17:19:45 +0000 (18:19 +0100)
committerRobert Varga <nite@hq.sk>
Wed, 28 Feb 2018 18:13:07 +0000 (18:13 +0000)
As it turns out, xtend does not do any sort of constant folding,
hence we need to share the strings instance ourselves to get
the most speed out of quick profile.

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

binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/YangTemplate.xtend

index 7c9ac94f6afe5694854235f5798d2ceff9710a00..16f18f697b13d303f342023882cf1fd2bf04e107 100644 (file)
@@ -44,13 +44,15 @@ class YangTemplate {
 
     private static val String SKIP_PROPERTY_NAME = "mdsal.skip.verbose"
 
-    private static val SKIP = Boolean.getBoolean(SKIP_PROPERTY_NAME);
+    private static val SKIP = Boolean.getBoolean(SKIP_PROPERTY_NAME)
+
+    private static val SKIPPED_EMPTY = '''(Empty due to «SKIP_PROPERTY_NAME» property = true)'''
 
     def static String generateYangSnipet(SchemaNode schemaNode) {
         if (schemaNode == null)
             return ''
         if (SKIP)
-            return '''(Empty due to «SKIP_PROPERTY_NAME» property = true)'''
+            return SKIPPED_EMPTY
         '''
             «IF schemaNode instanceof DataSchemaNode»
             «writeDataSchemaNode(schemaNode)»
@@ -89,7 +91,7 @@ class YangTemplate {
         if (nodes.nullOrEmpty)
             return ''
         if (SKIP)
-            return '''(Empty due to «SKIP_PROPERTY_NAME» property = true)'''
+            return SKIPPED_EMPTY
         '''
             «FOR node : nodes»
                 «IF node instanceof NotificationDefinition»
@@ -134,7 +136,7 @@ class YangTemplate {
 
     def static String generateYangSnipet(Module module) {
         if (SKIP)
-            return '''(Empty due to «SKIP_PROPERTY_NAME» property = true)'''
+            return SKIPPED_EMPTY
         '''
             module «module.name» {
                 yang-version «module.yangVersion»;