Skip to content

Commit 654ed90

Browse files
committed
refactor(queue): cleanup variables namespace
Signed-off-by: Jérôme Benoit <[email protected]>
1 parent 08bcec6 commit 654ed90

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

src/queues/abstract-fixed-queue.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,16 @@ export abstract class AbstractFixedQueue<T> implements IFixedQueue<T> {
7777
--this.size
7878
return true
7979
}
80-
let physicalShiftIndex = currentPhysicalIndex
80+
let shiftPhysicalIndex = currentPhysicalIndex
8181
for (let i = logicalIndex; i < this.size - 1; i++) {
82-
let nextPhysicalIndex = physicalShiftIndex + 1
82+
let nextPhysicalIndex = shiftPhysicalIndex + 1
8383
if (nextPhysicalIndex === this.capacity) {
8484
nextPhysicalIndex = 0
8585
}
86-
this.nodeArray[physicalShiftIndex] = this.nodeArray[nextPhysicalIndex]
87-
physicalShiftIndex = nextPhysicalIndex
86+
this.nodeArray[shiftPhysicalIndex] = this.nodeArray[nextPhysicalIndex]
87+
shiftPhysicalIndex = nextPhysicalIndex
8888
}
89-
this.nodeArray[physicalShiftIndex] = undefined
89+
this.nodeArray[shiftPhysicalIndex] = undefined
9090
--this.size
9191
return true
9292
}

src/queues/fixed-priority-queue.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,21 @@ export class FixedPriorityQueue<T> extends AbstractFixedQueue<T>
2727
currentPhysicalIndex = 0
2828
}
2929
}
30-
let end = this.start + this.size
31-
if (end >= this.capacity) {
32-
end -= this.capacity
30+
let endPhysicalIndex = this.start + this.size
31+
if (endPhysicalIndex >= this.capacity) {
32+
endPhysicalIndex -= this.capacity
3333
}
3434
if (insertionPhysicalIndex === -1) {
35-
insertionPhysicalIndex = end
35+
insertionPhysicalIndex = endPhysicalIndex
3636
} else {
37-
let toShiftIndex = end
38-
while (toShiftIndex !== insertionPhysicalIndex) {
39-
const previousIndex = toShiftIndex === 0
37+
let shiftPhysicalIndex = endPhysicalIndex
38+
while (shiftPhysicalIndex !== insertionPhysicalIndex) {
39+
const previousPhysicalIndex = shiftPhysicalIndex === 0
4040
? this.capacity - 1
41-
: toShiftIndex - 1
42-
this.nodeArray[toShiftIndex] = this.nodeArray[previousIndex]
43-
toShiftIndex = previousIndex
41+
: shiftPhysicalIndex - 1
42+
this.nodeArray[shiftPhysicalIndex] =
43+
this.nodeArray[previousPhysicalIndex]
44+
shiftPhysicalIndex = previousPhysicalIndex
4445
}
4546
}
4647
this.nodeArray[insertionPhysicalIndex] = { data, priority }

0 commit comments

Comments
 (0)