Skip to content

Commit 588976d

Browse files
committed
Deleting cache length size to loop
1 parent b27f737 commit 588976d

3 files changed

Lines changed: 32 additions & 32 deletions

File tree

‎lib/Compilation.js‎

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ function byId(a, b) {
3030
}
3131

3232
function iterationBlockVariable(variables, fn) {
33-
for(var indexVariable = 0, lenVariables = variables.length; indexVariable < lenVariables; indexVariable++) {
33+
for(var indexVariable = 0; indexVariable < variables.length; indexVariable++) {
3434
var varDep = variables[indexVariable].dependencies;
35-
for(var indexVDep = 0, lenVDep = varDep.length; indexVDep < lenVDep; indexVDep++) {
35+
for(var indexVDep = 0; indexVDep < varDep.length; indexVDep++) {
3636
fn(varDep[indexVDep]);
3737
}
3838
}
3939
}
4040

4141
function iterationOfArrayCallback(arr, fn) {
42-
for(var index = 0, len = arr.length; index < len; index++) {
42+
for(var index = 0; index < arr.length; index++) {
4343
fn(arr[index]);
4444
}
4545
}
@@ -141,7 +141,7 @@ class Compilation extends Tapable {
141141
}
142142
module.build(this.options, this, this.resolvers.normal, this.inputFileSystem, (error) => {
143143
var errors = module.errors;
144-
for(var indexError = 0, lenErrors = errors.length; indexError < lenErrors; indexError++) {
144+
for(var indexError = 0; indexError < errors.length; indexError++) {
145145
var err = errors[indexError];
146146
err.origin = origin;
147147
err.dependencies = dependencies;
@@ -152,7 +152,7 @@ class Compilation extends Tapable {
152152
}
153153

154154
var warnings = module.warnings;
155-
for(var indexWarning = 0, lenWarnings = warnings.length; indexWarning < lenWarnings; indexWarning++) {
155+
for(var indexWarning = 0; indexWarning < warnings.length; indexWarning++) {
156156
var war = warnings[indexWarning];
157157
war.origin = origin;
158158
war.dependencies = dependencies;
@@ -248,7 +248,7 @@ class Compilation extends Tapable {
248248
}
249249

250250
function iterationDependencies(depend) {
251-
for(var index = 0, len = depend.length; index < len; index++) {
251+
for(var index = 0; index < depend.length; index++) {
252252
var dep = depend[index];
253253
dep.module = dependentModule;
254254
dependentModule.addReason(module, dep);
@@ -521,7 +521,7 @@ class Compilation extends Tapable {
521521
var modules = this.modules;
522522
this.applyPlugins1("finish-modules", modules);
523523

524-
for(var index = 0, length = modules.length; index < length; index++) {
524+
for(var index = 0; index < modules.length; index++) {
525525
var module = modules[index];
526526
this.reportDependencyErrorsAndWarnings(module, [module]);
527527
}
@@ -653,16 +653,16 @@ class Compilation extends Tapable {
653653
}
654654

655655
reportDependencyErrorsAndWarnings(module, blocks) {
656-
for(var indexBlock = 0, lengthBlocks = blocks.length; indexBlock < lengthBlocks; indexBlock++) {
656+
for(var indexBlock = 0; indexBlock < blocks.length; indexBlock++) {
657657
var block = blocks[indexBlock];
658658
var dependencies = block.dependencies;
659659

660-
for(var indexDep = 0, lengthDep = dependencies.length; indexDep < lengthDep; indexDep++) {
660+
for(var indexDep = 0; indexDep < dependencies.length; indexDep++) {
661661
var d = dependencies[indexDep];
662662

663663
const warnings = d.getWarnings();
664664
if(warnings) {
665-
for(var indexWar = 0, lengthWar = warnings.length; indexWar < lengthWar; indexWar++) {
665+
for(var indexWar = 0; indexWar < warnings.length; indexWar++) {
666666
var w = warnings[indexWar];
667667

668668
var warning = new ModuleDependencyWarning(module, w, d.loc);
@@ -671,7 +671,7 @@ class Compilation extends Tapable {
671671
}
672672
const errors = d.getErrors();
673673
if(errors) {
674-
for(var indexErr = 0, lengthErr = errors.length; indexErr < lengthErr; indexErr++) {
674+
for(var indexErr = 0; indexErr < errors.length; indexErr++) {
675675
var e = errors[indexErr];
676676

677677
var error = new ModuleDependencyError(module, e, d.loc);
@@ -880,9 +880,9 @@ class Compilation extends Tapable {
880880
};
881881

882882
var blocks = block.blocks;
883-
for(var indexBlock = 0, lenBlocks = blocks.length; indexBlock < lenBlocks; indexBlock++) {
883+
for(var indexBlock = 0; indexBlock < blocks.length; indexBlock++) {
884884
var chunks = blocks[indexBlock].chunks;
885-
for(var indexChunk = 0, lenChunks = chunks.length; indexChunk < lenChunks; indexChunk++) {
885+
for(var indexChunk = 0; indexChunk < chunks.length; indexChunk++) {
886886
var blockChunk = chunks[indexChunk];
887887
chunk.removeChunk(blockChunk);
888888
blockChunk.removeParent(chunk);
@@ -915,7 +915,7 @@ class Compilation extends Tapable {
915915
}
916916

917917
var modules1 = this.modules;
918-
for(var indexModule1 = 0, lenModule1 = modules1.length; indexModule1 < lenModule1; indexModule1++) {
918+
for(var indexModule1 = 0; indexModule1 < modules1.length; indexModule1++) {
919919
var module1 = modules1[indexModule1];
920920
if(module1.id !== null && typeof usedIdMap[module1.id] === "undefined") {
921921
usedIds.push(module1.id);
@@ -934,7 +934,7 @@ class Compilation extends Tapable {
934934
}
935935

936936
var modules2 = this.modules;
937-
for(var indexModule2 = 0, lenModule2 = modules2.length; indexModule2 < lenModule2; indexModule2++) {
937+
for(var indexModule2 = 0; indexModule2 < modules2.length; indexModule2++) {
938938
var module2 = modules2[indexModule2];
939939
if(module2.id === null) {
940940
if(unusedIds.length > 0)
@@ -953,7 +953,7 @@ class Compilation extends Tapable {
953953
var keyChunks = Object.keys(usedChunkIds);
954954
var result = -1;
955955

956-
for(var index = 0, len = keyChunks.length; index < len; index++) {
956+
for(var index = 0; index < keyChunks.length; index++) {
957957
var usedIdKey = keyChunks[index];
958958
var usedIdValue = usedChunkIds[usedIdKey];
959959

@@ -977,7 +977,7 @@ class Compilation extends Tapable {
977977
}
978978

979979
var chunks = this.chunks;
980-
for(var indexChunk = 0, lenChunk = chunks.length; indexChunk < lenChunk; indexChunk++) {
980+
for(var indexChunk = 0; indexChunk < chunks.length; indexChunk++) {
981981
var chunk = chunks[indexChunk];
982982
if(chunk.id === null) {
983983
if(unusedIds.length > 0)
@@ -995,12 +995,12 @@ class Compilation extends Tapable {
995995
this.modules.sort(byId);
996996

997997
var modules = this.modules;
998-
for(var indexModule = 0, lenModules = modules.length; indexModule < lenModules; indexModule++) {
998+
for(var indexModule = 0; indexModule < modules.length; indexModule++) {
999999
modules[indexModule].sortItems();
10001000
}
10011001

10021002
var chunks = this.chunks;
1003-
for(var indexChunk = 0, lenChunk = chunks.length; indexChunk < lenChunk; indexChunk++) {
1003+
for(var indexChunk = 0; indexChunk < chunks.length; indexChunk++) {
10041004
chunks[indexChunk].sortItems();
10051005
}
10061006
}
@@ -1009,12 +1009,12 @@ class Compilation extends Tapable {
10091009
this.chunks.sort(byId);
10101010

10111011
var modules = this.modules;
1012-
for(var indexModule = 0, lenModules = modules.length; indexModule < lenModules; indexModule++) {
1012+
for(var indexModule = 0; indexModule < modules.length; indexModule++) {
10131013
modules[indexModule].sortItems();
10141014
}
10151015

10161016
var chunks = this.chunks;
1017-
for(var indexChunk = 0, lenChunk = chunks.length; indexChunk < lenChunk; indexChunk++) {
1017+
for(var indexChunk = 0; indexChunk < chunks.length; indexChunk++) {
10181018
chunks[indexChunk].sortItems();
10191019
}
10201020
}
@@ -1033,7 +1033,7 @@ class Compilation extends Tapable {
10331033
this.missingDependencies = [];
10341034

10351035
var children = this.children;
1036-
for(var indexChildren = 0, lenChildrens = children.length; indexChildren < lenChildrens; indexChildren++) {
1036+
for(var indexChildren = 0; indexChildren < children.length; indexChildren++) {
10371037
var child = children[indexChildren];
10381038

10391039
this.fileDependencies = this.fileDependencies.concat(child.fileDependencies);
@@ -1042,18 +1042,18 @@ class Compilation extends Tapable {
10421042
}
10431043

10441044
var modules = this.modules;
1045-
for(var indexModule = 0, lenModules = modules.length; indexModule < lenModules; indexModule++) {
1045+
for(var indexModule = 0; indexModule < modules.length; indexModule++) {
10461046
var module = modules[indexModule];
10471047

10481048
if(module.fileDependencies) {
10491049
var fileDependencies = module.fileDependencies;
1050-
for(var indexFileDep = 0, lenFileDeps = fileDependencies.length; indexFileDep < lenFileDeps; indexFileDep++) {
1050+
for(var indexFileDep = 0; indexFileDep < fileDependencies.length; indexFileDep++) {
10511051
this.fileDependencies.push(fileDependencies[indexFileDep]);
10521052
}
10531053
}
10541054
if(module.contextDependencies) {
10551055
var contextDependencies = module.contextDependencies;
1056-
for(var indexContextDep = 0, lenContextDeps = contextDependencies.length; indexContextDep < lenContextDeps; indexContextDep++) {
1056+
for(var indexContextDep = 0; indexContextDep < contextDependencies.length; indexContextDep++) {
10571057
this.contextDependencies.push(contextDependencies[indexContextDep]);
10581058
}
10591059
}
@@ -1213,15 +1213,15 @@ class Compilation extends Tapable {
12131213
const usedIds = {};
12141214

12151215
var modules = this.modules;
1216-
for(var indexModule = 0, lenModules = modules.length; indexModule < lenModules; indexModule++) {
1216+
for(var indexModule = 0; indexModule < modules.length; indexModule++) {
12171217
var moduleId = modules[indexModule].id;
12181218

12191219
if(usedIds[moduleId])
12201220
throw new Error(`checkConstraints: duplicate module id ${moduleId}`);
12211221
}
12221222

12231223
var chunks = this.chunks;
1224-
for(var indexChunk = 0, lenChunk = chunks.length; indexChunk < lenChunk; indexChunk++) {
1224+
for(var indexChunk = 0; indexChunk < chunks.length; indexChunk++) {
12251225
var chunk = chunks[indexChunk];
12261226

12271227
if(chunks.indexOf(chunk) !== indexChunk)

‎lib/Parser.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ Parser.prototype.walkCallExpression = function walkCallExpression(expression) {
857857
this.inScope(params.filter(function(identifier, idx) {
858858
return !args[idx];
859859
}), function() {
860-
for(var i = 0, len = args.length; i < len; i++) {
860+
for(var i = 0; i < args.length; i++) {
861861
var param = args[i];
862862
if(!param) continue;
863863
if(!params[i] || params[i].type !== "Identifier") continue;

‎lib/optimize/RemoveParentModulesPlugin.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function allHaveModule(someChunks, module, checkedChunks) {
3535
}
3636

3737
function addToSet(set, items) {
38-
for(var index = 0, lenItems = items.length; index < lenItems; index++) {
38+
for(var index = 0; index < items.length; index++) {
3939
var item = items[index];
4040

4141
if(set.indexOf(item) < 0) {
@@ -61,12 +61,12 @@ class RemoveParentModulesPlugin {
6161
apply(compiler) {
6262
compiler.plugin("compilation", (compilation) => {
6363
compilation.plugin(["optimize-chunks-basic", "optimize-extracted-chunks-basic"], (chunks) => {
64-
for(var index = 0, lenChunks = chunks.length; index < lenChunks; index++) {
64+
for(var index = 0; index < chunks.length; index++) {
6565
var chunk = chunks[index];
6666

67-
var cache = {};
67+
var cache = Object.create(null);
6868
var modules = chunk.modules.slice();
69-
for(var i = 0, lenChunk = modules.length; i < lenChunk; i++) {
69+
for(var i = 0; i < modules.length; i++) {
7070
var module = modules[i];
7171

7272
if(chunk.parents.length === 0) continue;

0 commit comments

Comments
 (0)