Skip to content

Commit 4438ac9

Browse files
committed
remove "removeAndDo" and make usage inline and explicit
1 parent 9e60f2c commit 4438ac9

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

‎lib/Chunk.js‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
const compareLocations = require("./compareLocations");
88
let debugId = 1000;
9-
const removeAndDo = require("./removeAndDo");
109

1110
const byId = (a, b) => {
1211
if(a.id < b.id) return -1;
@@ -97,15 +96,33 @@ class Chunk {
9796
}
9897

9998
removeModule(module) {
100-
removeAndDo(this.modules, module, "removeChunk", this);
99+
var idx = this.modules.indexOf(module);
100+
if(idx >= 0) {
101+
this.modules.splice(idx, 1);
102+
module.removeChunk(this);
103+
return true;
104+
}
105+
return false;
101106
}
102107

103108
removeChunk(chunk) {
104-
removeAndDo(this.chunks, chunk, "removeParent", this);
109+
var idx = this.chunks.indexOf(chunk);
110+
if(idx >= 0) {
111+
this.chunks.splice(idx, 1);
112+
chunk.removeParent(this);
113+
return true;
114+
}
115+
return false;
105116
}
106117

107118
removeParent(chunk) {
108-
removeAndDo(this.parents, chunk, "removeChunk", this);
119+
var idx = this.parents.indexOf(chunk);
120+
if(idx >= 0) {
121+
this.parents.splice(idx, 1);
122+
chunk.removeChunk(this);
123+
return true;
124+
}
125+
return false;
109126
}
110127

111128
addOrigin(module, loc) {

‎lib/Module.js‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
var DependenciesBlock = require("./DependenciesBlock");
66
var ModuleReason = require("./ModuleReason");
77
var Template = require("./Template");
8-
var removeAndDo = require("./removeAndDo");
98

109
var debugId = 1000;
1110

@@ -77,7 +76,13 @@ Module.prototype.addChunk = function(chunk) {
7776
};
7877

7978
Module.prototype.removeChunk = function(chunk) {
80-
return removeAndDo(this.chunks, chunk, "removeModule", this);
79+
var idx = this.chunks.indexOf(chunk);
80+
if(idx >= 0) {
81+
this.chunks.splice(idx, 1);
82+
chunk.removeModule(this);
83+
return true;
84+
}
85+
return false;
8186
};
8287

8388
Module.prototype.addReason = function(module, dependency) {

0 commit comments

Comments
 (0)