]> Piment Noir Git Repositories - poolifier.git/commitdiff
refactor(queue): cleanup variables namespace
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 13 Jul 2025 18:21:37 +0000 (20:21 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 13 Jul 2025 18:21:37 +0000 (20:21 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/queues/abstract-fixed-queue.ts
src/queues/fixed-priority-queue.ts

index 3d77377d1b513a46b4599396b292be961a380bba..b22b248604dcb0f7daa3d0f0ae4de50f60a5ee96 100644 (file)
@@ -66,16 +66,16 @@ export abstract class AbstractFixedQueue<T> implements IFixedQueue<T> {
         --this.size
         return true
       }
-      let physicalShiftIndex = currentPhysicalIndex
+      let shiftPhysicalIndex = currentPhysicalIndex
       for (let i = logicalIndex; i < this.size - 1; i++) {
-        let nextPhysicalIndex = physicalShiftIndex + 1
+        let nextPhysicalIndex = shiftPhysicalIndex + 1
         if (nextPhysicalIndex === this.capacity) {
           nextPhysicalIndex = 0
         }
-        this.nodeArray[physicalShiftIndex] = this.nodeArray[nextPhysicalIndex]
-        physicalShiftIndex = nextPhysicalIndex
+        this.nodeArray[shiftPhysicalIndex] = this.nodeArray[nextPhysicalIndex]
+        shiftPhysicalIndex = nextPhysicalIndex
       }
-      this.nodeArray[physicalShiftIndex] = undefined
+      this.nodeArray[shiftPhysicalIndex] = undefined
       --this.size
       return true
     }
index 35b262d6e74d887d196eb3d2961a9f1dc64f57ed..c5fc17aeefd998114d7222c976703990f128d770 100644 (file)
@@ -29,19 +29,20 @@ export class FixedPriorityQueue<T>
         currentPhysicalIndex = 0
       }
     }
-    let end = this.start + this.size
-    if (end >= this.capacity) {
-      end -= this.capacity
+    let endPhysicalIndex = this.start + this.size
+    if (endPhysicalIndex >= this.capacity) {
+      endPhysicalIndex -= this.capacity
     }
     if (insertionPhysicalIndex === -1) {
-      insertionPhysicalIndex = end
+      insertionPhysicalIndex = endPhysicalIndex
     } else {
-      let toShiftIndex = end
-      while (toShiftIndex !== insertionPhysicalIndex) {
-        const previousIndex =
-          toShiftIndex === 0 ? this.capacity - 1 : toShiftIndex - 1
-        this.nodeArray[toShiftIndex] = this.nodeArray[previousIndex]
-        toShiftIndex = previousIndex
+      let shiftPhysicalIndex = endPhysicalIndex
+      while (shiftPhysicalIndex !== insertionPhysicalIndex) {
+        const previousPhysicalIndex =
+          shiftPhysicalIndex === 0 ? this.capacity - 1 : shiftPhysicalIndex - 1
+        this.nodeArray[shiftPhysicalIndex] =
+          this.nodeArray[previousPhysicalIndex]
+        shiftPhysicalIndex = previousPhysicalIndex
       }
     }
     this.nodeArray[insertionPhysicalIndex] = { data, priority }