Compare commits

..

1 Commits

Author SHA1 Message Date
Bertie690
3723b68c2e
Merge 018a0091f3 into 6c0253ada4 2025-08-10 23:43:44 -04:00

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;
} }
} }