mirror of https://github.com/webpack/webpack.git
avoiding v8 deopts
This commit is contained in:
parent
9d05b680f0
commit
50bb510d65
|
|
@ -192,18 +192,6 @@ const bySetSize = (a, b) => {
|
|||
return a.size - b.size;
|
||||
};
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {T[]} arr array of elements to iterate over
|
||||
* @param {function(T): void} fn callback applied to each element
|
||||
* @returns {void}
|
||||
*/
|
||||
const iterationOfArrayCallback = (arr, fn) => {
|
||||
for (let index = 0; index < arr.length; index++) {
|
||||
fn(arr[index]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {Set<T>} set set to add items to
|
||||
|
|
@ -787,10 +775,10 @@ class Compilation {
|
|||
const processDependenciesBlock = block => {
|
||||
if (block.dependencies) {
|
||||
currentBlock = block;
|
||||
iterationOfArrayCallback(block.dependencies, processDependency);
|
||||
for (const dep of block.dependencies) processDependency(dep);
|
||||
}
|
||||
if (block.blocks) {
|
||||
iterationOfArrayCallback(block.blocks, processDependenciesBlock);
|
||||
for (const b of block.blocks) processDependenciesBlock(b);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -1633,11 +1621,11 @@ class Compilation {
|
|||
*/
|
||||
const assignDepthToDependencyBlock = block => {
|
||||
if (block.dependencies) {
|
||||
iterationOfArrayCallback(block.dependencies, assignDepthToDependency);
|
||||
for (const dep of block.dependencies) assignDepthToDependency(dep);
|
||||
}
|
||||
|
||||
if (block.blocks) {
|
||||
iterationOfArrayCallback(block.blocks, assignDepthToDependencyBlock);
|
||||
for (const b of block.blocks) assignDepthToDependencyBlock(b);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -1736,11 +1724,11 @@ class Compilation {
|
|||
blockInfoBlocks = [];
|
||||
|
||||
if (block.dependencies) {
|
||||
iterationOfArrayCallback(block.dependencies, iteratorDependency);
|
||||
for (const dep of block.dependencies) iteratorDependency(dep);
|
||||
}
|
||||
|
||||
if (block.blocks) {
|
||||
iterationOfArrayCallback(block.blocks, iteratorBlockPrepare);
|
||||
for (const b of block.blocks) iteratorBlockPrepare(b);
|
||||
}
|
||||
|
||||
const blockInfo = {
|
||||
|
|
@ -1944,7 +1932,7 @@ class Compilation {
|
|||
}
|
||||
|
||||
// Traverse all Blocks
|
||||
iterationOfArrayCallback(blockInfo.blocks, iteratorBlock);
|
||||
for (const block of blockInfo.blocks) iteratorBlock(block);
|
||||
|
||||
if (blockInfo.blocks.length > 0 && module !== block) {
|
||||
blocksWithNestedBlocks.add(block);
|
||||
|
|
@ -2150,13 +2138,13 @@ class Compilation {
|
|||
};
|
||||
|
||||
if (block.blocks) {
|
||||
iterationOfArrayCallback(block.blocks, block =>
|
||||
this.removeReasonsOfDependencyBlock(module, block)
|
||||
);
|
||||
for (const b of block.blocks) {
|
||||
this.removeReasonsOfDependencyBlock(module, b);
|
||||
}
|
||||
}
|
||||
|
||||
if (block.dependencies) {
|
||||
iterationOfArrayCallback(block.dependencies, iteratorDependency);
|
||||
for (const dep of block.dependencies) iteratorDependency(dep);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2207,7 +2195,7 @@ class Compilation {
|
|||
}
|
||||
|
||||
if (block.dependencies) {
|
||||
iterationOfArrayCallback(block.dependencies, iteratorDependency);
|
||||
for (const dep of block.dependencies) iteratorDependency(dep);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -250,7 +250,12 @@ const normalizeSizes = value => {
|
|||
* @returns {SplitChunksSizes} the merged sizes
|
||||
*/
|
||||
const mergeSizes = (...sizes) => {
|
||||
return Object.assign({}, ...sizes.map(normalizeSizes).reverse());
|
||||
/** @type {SplitChunksSizes} */
|
||||
let merged = {};
|
||||
for (let i = sizes.length - 1; i >= 0; i--) {
|
||||
merged = Object.assign(merged, normalizeSizes(sizes[i]));
|
||||
}
|
||||
return merged;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
"ajv": "^6.1.0",
|
||||
"ajv-keywords": "^3.1.0",
|
||||
"chrome-trace-event": "^1.0.0",
|
||||
"enhanced-resolve": "5.0.0-beta.1",
|
||||
"enhanced-resolve": "5.0.0-beta.2",
|
||||
"eslint-scope": "^4.0.0",
|
||||
"events": "^3.0.0",
|
||||
"find-cache-dir": "^2.1.0",
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
"loader-utils": "^1.1.0",
|
||||
"neo-async": "^2.6.0",
|
||||
"schema-utils": "^1.0.0",
|
||||
"tapable": "2.0.0-beta.5",
|
||||
"tapable": "2.0.0-beta.8",
|
||||
"terser-webpack-plugin": "^1.2.1",
|
||||
"watchpack": "2.0.0-beta.6",
|
||||
"webpack-sources": "2.0.0-beta.1"
|
||||
|
|
|
|||
18
yarn.lock
18
yarn.lock
|
|
@ -1591,13 +1591,13 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0:
|
|||
dependencies:
|
||||
once "^1.4.0"
|
||||
|
||||
enhanced-resolve@5.0.0-beta.1:
|
||||
version "5.0.0-beta.1"
|
||||
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.0.0-beta.1.tgz#600c242ec84a31f7198e165ea08143eef2cc3a04"
|
||||
integrity sha512-dlCyQrjJDL/RJzVWzZkrO5aL8EYCGpMvqGv5IPwaVCO8yLMs+rQuuMczeOxYNj0hD2DAtOGAfvocgDkzbNCmDg==
|
||||
enhanced-resolve@5.0.0-beta.2:
|
||||
version "5.0.0-beta.2"
|
||||
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.0.0-beta.2.tgz#9dfd00b7d73e7d6e0acab9e1f54241a557edbe8d"
|
||||
integrity sha512-qo97XNV7JrYZR9eaFRPfKtOtiF1RBTGIx9v+j5DttaZyAhwgXnhs69YYTzEKgQpiOW8snnAiVdp5/eu+d3/55g==
|
||||
dependencies:
|
||||
graceful-fs "^4.2.0"
|
||||
tapable "^2.0.0-beta"
|
||||
tapable "^2.0.0-beta.8"
|
||||
|
||||
errno@^0.1.1, errno@^0.1.3, errno@~0.1.7:
|
||||
version "0.1.7"
|
||||
|
|
@ -5336,10 +5336,10 @@ table@^5.2.3:
|
|||
slice-ansi "^2.1.0"
|
||||
string-width "^3.0.0"
|
||||
|
||||
tapable@2.0.0-beta.5, tapable@^2.0.0-beta:
|
||||
version "2.0.0-beta.5"
|
||||
resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.0.0-beta.5.tgz#51def4d94c58ad8fadf00cac7661216502fe9c70"
|
||||
integrity sha512-P4o84kC8CD66ZuCs6noh3QLU2ZuaBvMl0yCmp9rr0GXZyIfLd1sB2ZvJZjitQgfds8GDKRLmiiAcssr2bEHQ0A==
|
||||
tapable@2.0.0-beta.8, tapable@^2.0.0-beta.8:
|
||||
version "2.0.0-beta.8"
|
||||
resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.0.0-beta.8.tgz#0a8d42f6895d43d5a895de15d9a9e3e425f72a0a"
|
||||
integrity sha512-7qMajFcHb2O+aWufLoAvKhEehIwikXUTH1s8RP4R5gSYMIB0Tmypp+J90EtSNVbIlI7oB0Oz8ZlpJUJlZ5owxQ==
|
||||
|
||||
terser-webpack-plugin@^1.2.1:
|
||||
version "1.3.0"
|
||||
|
|
|
|||
Loading…
Reference in New Issue