Skip to content

Commit

Permalink
fixed files form Closure #105
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent d9d7016 commit b4007ec
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1474,30 +1474,32 @@ void tryFoldStringJoin(NodeTraversal t, Node n, Node left, Node right,

String joinString = NodeUtil.getStringValue(right);
List<Node> arrayFoldedChildren = Lists.newLinkedList();
StringBuilder sb = new StringBuilder();
StringBuilder sb = null;
int foldedSize = 0;
Node elem = arrayNode.getFirstChild();
// Merges adjacent String nodes.
while (elem != null) {
if (NodeUtil.isImmutableValue(elem)) {
if (sb.length() > 0) {
if (sb == null) {
sb = new StringBuilder();
} else {
sb.append(joinString);
}
sb.append(NodeUtil.getStringValue(elem));
} else {
if (sb.length() > 0) {
if (sb != null) {
// + 2 for the quotes.
foldedSize += sb.length() + 2;
arrayFoldedChildren.add(Node.newString(sb.toString()));
sb = new StringBuilder();
sb = null;
}
foldedSize += InlineCostEstimator.getCost(elem);
arrayFoldedChildren.add(elem);
}
elem = elem.getNext();
}

if (sb.length() > 0) {
if (sb != null) {
// + 2 for the quotes.
foldedSize += sb.length() + 2;
arrayFoldedChildren.add(Node.newString(sb.toString()));
Expand Down

0 comments on commit b4007ec

Please sign in to comment.