From 7720f67ca3869a201735fe2616cecab7dda0bafc Mon Sep 17 00:00:00 2001 From: Alex Galays Date: Thu, 13 Nov 2014 16:10:45 +0100 Subject: [PATCH] Performance tuning: Push in an existing Array instance, instead of recreating an Array every time with concat. --- mithril.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mithril.js b/mithril.js index d727537f..5065b3c4 100644 --- a/mithril.js +++ b/mithril.js @@ -194,7 +194,11 @@ Mithril = m = new function app(window, undefined) { //update the list of DOM nodes by collecting the nodes from each item for (var i = 0; i < data.length; i++) { - if (cached[i] != null) nodes = nodes.concat(cached[i].nodes) + if (cached[i] != null) { + for (var j = 0; j < cached[i].nodes.length; j++) { + nodes.push(cached[i].nodes[j]); + } + } } //remove items from the end of the array if the new array is shorter than the old one //if errors ever happen here, the issue is most likely a bug in the construction of the `cached` data structure somewhere earlier in the program