inline flatten

This commit is contained in:
Leo Horie 2014-11-14 22:54:16 -05:00
parent 6736537fcf
commit 1321aec9fb

View file

@ -108,7 +108,14 @@ Mithril = m = new function app(window, undefined) {
}
if (dataType == sArr) {
data = flatten(data);
//recursively flatten array
for (var i = 0; i < data.length; i++) {
if (type.call(data[i]) == sArr) {
data = data.concat.apply([], data);
i-- //check current index again and flatten until there are no more nested arrays at that index
}
}
var nodes = [], intact = cached.length === data.length, subArrayCount = 0;
//keys algorithm: sort elements without recreating them if keys are present
@ -390,16 +397,6 @@ Mithril = m = new function app(window, undefined) {
}
return nodes
}
function flatten(data) {
//recursive flatten
for (var i = 0; i < data.length; i++) {
if (type.call(data[i]) == sArr) {
data = data.concat.apply([], data);
i-- //check current index again and flatten until there are no more nested arrays at that index
}
}
return data
}
function autoredraw(callback, object) {
return function(e) {
e = e || event;