Compare commits

..

No commits in common. "c1c66a473b6be0e99ce899d64ee5bc63f8f22eba" and "018a0091f382e0baac7aef43b6501f4357075fa8" have entirely different histories.

View File

@ -54,22 +54,19 @@ export abstract class PhasePriorityQueue {
* @todo Remove this eventually once the patchwork bug this is used for is fixed * @todo Remove this eventually once the patchwork bug this is used for is fixed
*/ */
public tryRemovePhase(phaseFilter: (phase: Phase) => boolean, removeCount: number | "all" = 1): number { public tryRemovePhase(phaseFilter: (phase: Phase) => boolean, removeCount: number | "all" = 1): number {
if (removeCount === "all") { if (typeof removeCount === "string") {
removeCount = Number.MAX_SAFE_INTEGER; removeCount = Number.MAX_SAFE_INTEGER; // For the lulz
} else if (removeCount < 1) {
return 0;
} }
let numRemoved = 0; let numRemoved = 0;
let phaseIndex = this.queue.findIndex(phaseFilter); let phaseIndex = this.queue.findIndex(phaseFilter);
if (phaseIndex === -1) { if (phaseIndex === -1) {
return 0; return 0;
} }
while (numRemoved < removeCount && phaseIndex !== -1) { do {
this.queue.splice(phaseIndex, 1); this.queue.splice(phaseIndex, 1);
numRemoved++; numRemoved++;
phaseIndex = this.queue.findIndex(phaseFilter); } while (numRemoved < removeCount || (phaseIndex = this.queue.findIndex(phaseFilter)) !== -1);
} return removeCount;
return numRemoved;
} }
} }