@@ -153,17 +153,15 @@ library HeapOrdering {
153153 uint256 size = _heap.size;
154154 Account memory accountToShift = getAccount (_heap, _rank);
155155 uint256 valueToShift = accountToShift.value;
156- Account memory childToSwap;
157- Account memory rightChild;
158156 uint256 childRank = _rank << 1 ;
159157 // At this point, childRank (resp. childRank+1) is the rank of the left (resp. right) child.
160158
161159 while (childRank <= size) {
162- childToSwap = getAccount (_heap, childRank);
160+ Account memory childToSwap = getAccount (_heap, childRank);
163161
164162 // Find the child with largest value.
165163 if (childRank < size) {
166- rightChild = getAccount (_heap, childRank + 1 );
164+ Account memory rightChild = getAccount (_heap, childRank + 1 );
167165 if (rightChild.value > childToSwap.value) {
168166 unchecked {
169167 ++ childRank; // This cannot overflow because childRank < size.
@@ -299,7 +297,7 @@ library HeapOrdering {
299297 /// @param _heap The heap to get the head.
300298 /// @return The address of the head.
301299 function getHead (HeapArray storage _heap ) internal view returns (address ) {
302- if (_heap.accounts.length > 0 ) return getAccount (_heap, 1 ).id;
300+ if (_heap.accounts.length > 0 ) return getAccount (_heap, ROOT ).id;
303301 else return address (0 );
304302 }
305303
0 commit comments