@@ -153,17 +153,15 @@ library HeapOrdering {
153
153
uint256 size = _heap.size;
154
154
Account memory accountToShift = getAccount (_heap, _rank);
155
155
uint256 valueToShift = accountToShift.value;
156
- Account memory childToSwap;
157
- Account memory rightChild;
158
156
uint256 childRank = _rank << 1 ;
159
157
// At this point, childRank (resp. childRank+1) is the rank of the left (resp. right) child.
160
158
161
159
while (childRank <= size) {
162
- childToSwap = getAccount (_heap, childRank);
160
+ Account memory childToSwap = getAccount (_heap, childRank);
163
161
164
162
// Find the child with largest value.
165
163
if (childRank < size) {
166
- rightChild = getAccount (_heap, childRank + 1 );
164
+ Account memory rightChild = getAccount (_heap, childRank + 1 );
167
165
if (rightChild.value > childToSwap.value) {
168
166
unchecked {
169
167
++ childRank; // This cannot overflow because childRank < size.
@@ -299,7 +297,7 @@ library HeapOrdering {
299
297
/// @param _heap The heap to get the head.
300
298
/// @return The address of the head.
301
299
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;
303
301
else return address (0 );
304
302
}
305
303
0 commit comments