this function was extremely slow. (#3264)
this fix reduces the time to process 165k installations from 282738.599ms (almost 5 minutes of total server lockup!) to just 16.283ms!
This commit is contained in:
committed by
Florent Vilmart
parent
9fd34fd25e
commit
ac3f5cd686
@@ -5,14 +5,15 @@ const PUSH_STATUS_COLLECTION = '_PushStatus';
|
|||||||
const JOB_STATUS_COLLECTION = '_JobStatus';
|
const JOB_STATUS_COLLECTION = '_JobStatus';
|
||||||
|
|
||||||
export function flatten(array) {
|
export function flatten(array) {
|
||||||
return array.reduce((memo, element) => {
|
var flattened = [];
|
||||||
if (Array.isArray(element)) {
|
for(var i = 0; i < array.length; i++) {
|
||||||
memo = memo.concat(flatten(element));
|
if(Array.isArray(array[i])) {
|
||||||
|
flattened = flattened.concat(flatten(array[i]));
|
||||||
} else {
|
} else {
|
||||||
memo = memo.concat(element);
|
flattened.push(array[i]);
|
||||||
}
|
}
|
||||||
return memo;
|
}
|
||||||
}, []);
|
return flattened;
|
||||||
}
|
}
|
||||||
|
|
||||||
function statusHandler(className, database) {
|
function statusHandler(className, database) {
|
||||||
|
|||||||
Reference in New Issue
Block a user