amd-optimize icon indicating copy to clipboard operation
amd-optimize copied to clipboard

collectModules is too slow

Open satoshi-izawa opened this issue 9 years ago • 1 comments

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;
  };

satoshi-izawa avatar Feb 26 '16 07:02 satoshi-izawa

Our product execute collector 90406870 times. after this change,collector is executed 499 times.

satoshi-izawa avatar Feb 26 '16 07:02 satoshi-izawa