You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2013/05/13 15:04:49 UTC
git commit: WICKET-5186 Use arrays instead of String concatenation in
JavaScript for better performance
Updated Branches:
refs/heads/master a11ce8a7e -> 3c7d371ea
WICKET-5186 Use arrays instead of String concatenation in JavaScript for better performance
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/3c7d371e
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/3c7d371e
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/3c7d371e
Branch: refs/heads/master
Commit: 3c7d371ea7cd787b0c931779c30e54d7b34b9f6d
Parents: a11ce8a
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon May 13 15:38:50 2013 +0300
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Mon May 13 15:38:50 2013 +0300
----------------------------------------------------------------------
.../wicket/ajax/res/js/wicket-ajax-jquery.js | 54 +++++++++------
1 files changed, 34 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/3c7d371e/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
index e4930ec..7a17267 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
@@ -1629,7 +1629,7 @@
if (isUndef(node)) {
return "";
}
- var result = "";
+ var result = [];
if (node.childNodes.length > 0) {
for (var i = 0; i < node.childNodes.length; i++) {
@@ -1637,50 +1637,60 @@
switch (thisNode.nodeType) {
case 1: // ELEMENT_NODE
case 5: // ENTITY_REFERENCE_NODE
- result += this.serializeNode(thisNode);
+ result.push(this.serializeNode(thisNode));
break;
case 8: // COMMENT
- result += "<!--" + thisNode.nodeValue + "-->";
+ result.push("<!--");
+ result.push(thisNode.nodeValue);
+ result.push("-->");
break;
case 4: // CDATA_SECTION_NODE
- result += "<![CDATA[" + thisNode.nodeValue + "]]>";
+ result.push("<![CDATA[");
+ result.push(thisNode.nodeValue);
+ result.push("]]>");
break;
case 3: // TEXT_NODE
case 2: // ATTRIBUTE_NODE
- result += thisNode.nodeValue;
+ result.push(thisNode.nodeValue);
break;
default:
break;
}
}
} else {
- result += node.textContent || node.text;
+ result.push(node.textContent || node.text);
}
- return result;
+ return result.join("");
},
serializeNode: function (node){
if (isUndef(node)) {
return "";
}
- var result = "";
- result += '<' + node.nodeName;
+ var result = [];
+ result.push("<");
+ result.push(node.nodeName);
if (node.attributes && node.attributes.length > 0) {
for (var i = 0; i < node.attributes.length; i++) {
// serialize the attribute only if it has meaningful value that is not inherited
if (node.attributes[i].nodeValue && node.attributes[i].specified) {
- result += " " + node.attributes[i].name +
- "=\"" + node.attributes[i].value + "\"";
+ result.push(" ");
+ result.push(node.attributes[i].name);
+ result.push("=\"");
+ result.push(node.attributes[i].value);
+ result.push("\"");
}
}
}
- result += '>';
- result += Wicket.DOM.serializeNodeChildren(node);
- result += '</' + node.nodeName + '>';
- return result;
+ result.push(">");
+ result.push(Wicket.DOM.serializeNodeChildren(node));
+ result.push("</");
+ result.push(node.nodeName);
+ result.push(">");
+ return result.join("");
},
// Utility function that determines whether given element is part of the current document
@@ -1699,7 +1709,11 @@
* @param node the root node
*/
text: function (node) {
- var result = "";
+ if (isUndef(node)) {
+ return "";
+ }
+
+ var result = [];
if (node.childNodes.length > 0) {
for (var i = 0; i < node.childNodes.length; i++) {
@@ -1707,21 +1721,21 @@
switch (thisNode.nodeType) {
case 1: // ELEMENT_NODE
case 5: // ENTITY_REFERENCE_NODE
- result += this.text(thisNode);
+ result.push(this.text(thisNode));
break;
case 3: // TEXT_NODE
case 4: // CDATA_SECTION_NODE
- result += thisNode.nodeValue;
+ result.push(thisNode.nodeValue);
break;
default:
break;
}
}
} else {
- result += node.textContent || node.text;
+ result.push(node.textContent || node.text);
}
- return result;
+ return result.join("");
}
},