Skip to content

Commit

Permalink
[ParU] Small code simplification
Browse files Browse the repository at this point in the history
Drop variable *el, use elementList[e] directly.
Replace using "continue" by inverted if condition and
moving the remaining code in the if block.
  • Loading branch information
gruenich committed Nov 11, 2023
1 parent 277c752 commit 438bcfb
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions ParU/Source/paru_heap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,15 @@ ParU_Ret paru_make_heap(int64_t f, int64_t start_fac,

for (int64_t e : pivotal_elements)
{
paru_element *el = elementList[e];
#ifndef NDEBUG
assert(el != NULL);
assert(elementList[e] != NULL);
#endif
if (el == NULL) continue;
PRLEVEL(PR, ("" LD " ", e));
curHeap->push_back(e);
std::push_heap(curHeap->begin(), curHeap->end(), greater);
if (elementList[e] != NULL)
{
PRLEVEL(PR, ("" LD " ", e));
curHeap->push_back(e);
std::push_heap(curHeap->begin(), curHeap->end(), greater);
}
}
curHeap->push_back(eli);
std::push_heap(curHeap->begin(), curHeap->end(), greater);
Expand Down Expand Up @@ -270,11 +271,12 @@ ParU_Ret paru_make_heap_empty_el(int64_t f, std::vector<int64_t> &pivotal_elemen

for (int64_t e : pivotal_elements)
{
paru_element *el = elementList[e];
if (el == NULL) continue;
PRLEVEL(PR, ("" LD " ", e));
curHeap->push_back(e);
std::push_heap(curHeap->begin(), curHeap->end(), greater);
if (elementList[e] != NULL)
{
PRLEVEL(PR, ("" LD " ", e));
curHeap->push_back(e);
std::push_heap(curHeap->begin(), curHeap->end(), greater);
}
}
std::push_heap(curHeap->begin(), curHeap->end(), greater);
PRLEVEL(PR, ("%% " LD " pushed ", eli));
Expand Down

0 comments on commit 438bcfb

Please sign in to comment.