freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [13/15] incubator-freemarker git commit: A bit of stripText optimization
Date Sun, 13 Dec 2015 16:02:30 GMT
A bit of stripText optimization


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/c82edf08
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/c82edf08
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/c82edf08

Branch: refs/heads/2.3-gae
Commit: c82edf0859f4ad0272dc50c227553cbcc7272b2e
Parents: 2e39196
Author: ddekany <ddekany@apache.org>
Authored: Sun Dec 13 16:24:55 2015 +0100
Committer: ddekany <ddekany@apache.org>
Committed: Sun Dec 13 16:24:55 2015 +0100

----------------------------------------------------------------------
 src/main/javacc/FTL.jj | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/c82edf08/src/main/javacc/FTL.jj
----------------------------------------------------------------------
diff --git a/src/main/javacc/FTL.jj b/src/main/javacc/FTL.jj
index 76533f3..254c27a 100644
--- a/src/main/javacc/FTL.jj
+++ b/src/main/javacc/FTL.jj
@@ -3925,7 +3925,7 @@ TextBlock PCData() :
         }
     )+
     {
-        if (stripText && mixedContentNesting == 1) return new TextBlock(CollectionUtils.EMPTY_CHAR_ARRAY,
false);
+        if (stripText && mixedContentNesting == 1) return null;
 
         TextBlock result = new TextBlock(buf.toString(), false);
         result.setLocation(template, start, t);
@@ -3980,17 +3980,20 @@ TemplateElements MixedContentElements() :
             elem = FreemarkerDirective()
         )
         {
-            childCount++;
-            if (childBuffer == null) {
-                childBuffer = new TemplateElement[16]; 
-            } else if (childBuffer.length < childCount) {
-                TemplateElement[] newChildBuffer = new TemplateElement[childCount * 2];
-                for (int i = 0; i < childBuffer.length; i++) {
-                    newChildBuffer[i] = childBuffer[i];
-                }
-                childBuffer = newChildBuffer;
+            // Note: elem == null when it's was top-level PCData removed by stripText
+            if (elem != null) {
+	            childCount++;
+	            if (childBuffer == null) {
+	                childBuffer = new TemplateElement[16]; 
+	            } else if (childBuffer.length < childCount) {
+	                TemplateElement[] newChildBuffer = new TemplateElement[childCount * 2];
+	                for (int i = 0; i < childBuffer.length; i++) {
+	                    newChildBuffer[i] = childBuffer[i];
+	                }
+	                childBuffer = newChildBuffer;
+	            }
+	            childBuffer[childCount - 1] = elem;
             }
-            childBuffer[childCount - 1] = elem;
         }
     )*
     {


Mime
View raw message