You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by dd...@apache.org on 2015/12/15 23:23:54 UTC
[13/23] incubator-freemarker git commit: A bit of stripText
optimization
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
Commit: c82edf0859f4ad0272dc50c227553cbcc7272b2e
Parents: 2e39196
Author: ddekany <dd...@apache.org>
Authored: Sun Dec 13 16:24:55 2015 +0100
Committer: ddekany <dd...@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;
}
)*
{