Skip to content

Commit d168bf0

Browse files
Reducing Cognitive code complexity
1 parent ea03c38 commit d168bf0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/data_structures/priority_queue.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ class PriorityQueue {
5555
*/
5656
_fixBottomHeap(idx) {
5757
let changeIdx = idx;
58-
let childIdx = (idx << 1) + 1;
59-
while (childIdx <= (idx << 1) + 2) {
58+
let childIdx = idx * 2 + 1;
59+
let rightChildIdx = idx * 2 + 2;
60+
while (childIdx <= rightChildIdx) {
6061
if (childIdx < this._size && this.comparison(
6162
this._priorityHeap[childIdx], this._priorityHeap[changeIdx])) {
6263
changeIdx = childIdx;

0 commit comments

Comments
 (0)