amd-optimize
amd-optimize copied to clipboard
collectModules is too slow
please apply this
collectModules = function(module, omitInline) {
var collector, outputBuffer;
if (omitInline == null) {
omitInline = true;
}
outputBuffer = [];
var moduleHash={};
collector = function(currentModule) {
currentModule.deps.forEach(function(depModule) {
if(moduleHash[depModule.name]){
return;
}else{
moduleHash[depModule.name]=true;
}
return collector(depModule);
});
if (!(omitInline && currentModule.isInline)) {
return outputBuffer.push(currentModule);
}
};
collector(module);
return outputBuffer;
};
Our product execute collector 90406870 times. after this change,collector is executed 499 times.