Prefer assignment over push

jsperf made me do it http://jsperf.com/array-direct-assignment-vs-push/5
This commit is contained in:
Tom MacWright
2012-11-06 12:43:27 -05:00
parent 525f9fdc51
commit 50f8e7f224
+3 -3
View File
@@ -19,7 +19,7 @@ iD.Connection = function(graph) {
function getNodes(obj) {
var nodes = [], nelems = obj.getElementsByTagName('nd');
for (var i = 0; i < nelems.length; i++) {
nodes.push(+nelems[i].attributes.ref.nodeValue);
nodes[i] = +nelems[i].attributes.ref.nodeValue;
}
return nodes;
}
@@ -40,11 +40,11 @@ iD.Connection = function(graph) {
elems = obj.getElementsByTagName('member');
for (var i = 0; i < elems.length; i++) {
members.push({
members[i] = {
id: +elems[i].attributes.ref.nodeValue,
type: elems[i].attributes.type.nodeValue,
role: elems[i].attributes.role.nodeValue
});
};
}
return members;