Skip to content

Commit fb9b61b

Browse files
committed
Avoid needless sort in Chunk compare
1 parent 09b6eae commit fb9b61b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/Chunk.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,17 +313,17 @@ class Chunk {
313313
* @returns {-1|0|1} this is a comparitor function like sort and returns -1, 0, or 1 based on sort order
314314
*/
315315
compareTo(otherChunk) {
316-
this._modules.sort();
317-
otherChunk._modules.sort();
318316
if (this._modules.size > otherChunk._modules.size) return -1;
319317
if (this._modules.size < otherChunk._modules.size) return 1;
318+
this._modules.sort();
319+
otherChunk._modules.sort();
320320
const a = this._modules[Symbol.iterator]();
321321
const b = otherChunk._modules[Symbol.iterator]();
322322
// eslint-disable-next-line no-constant-condition
323323
while (true) {
324324
const aItem = a.next();
325-
const bItem = b.next();
326325
if (aItem.done) return 0;
326+
const bItem = b.next();
327327
const aModuleIdentifier = aItem.value.identifier();
328328
const bModuleIdentifier = bItem.value.identifier();
329329
if (aModuleIdentifier < bModuleIdentifier) return -1;

0 commit comments

Comments
 (0)