Skip to content

Commit 9f27e92

Browse files
committed
use replaceChunk and replaceParent in "integrate" method
1 parent 848b5ae commit 9f27e92

1 file changed

Lines changed: 4 additions & 19 deletions

File tree

lib/Chunk.js

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -198,27 +198,12 @@ class Chunk {
198198
otherModules.forEach(m => other.moveModule(m, this));
199199
other.modules.length = 0;
200200

201-
const moveChunks = (chunks, kind, onChunk) => {
202-
chunks.forEach(c => {
203-
const idx = c[kind].indexOf(other);
204-
if(idx >= 0) {
205-
c[kind].splice(idx, 1);
206-
}
207-
onChunk(c);
208-
});
209-
};
210-
moveChunks(other.parents, "chunks", c => {
211-
if(c !== this && this.addParent(c)) {
212-
c.addChunk(this);
213-
}
214-
});
201+
other.parents.forEach(parent => parent.replaceChunk(other, this));
215202
other.parents.length = 0;
216-
moveChunks(other.chunks, "parents", c => {
217-
if(c !== this && this.addChunk(c)) {
218-
c.addParent(this);
219-
}
220-
});
203+
204+
other.chunks.forEach(chunk => chunk.replaceParent(other, this));
221205
other.chunks.length = 0;
206+
222207
other.blocks.forEach(b => {
223208
b.chunks = (b.chunks || [this]).map(c => {
224209
return c === other ? this : c;

0 commit comments

Comments
 (0)