Skip to content

Commit

Permalink
[ParU] Small performance improvement in update rowDeg
Browse files Browse the repository at this point in the history
std::set only inserts an element, if it does not already contain
the element. Thus, we can get rid of the additional find.

This was found by cppcheck.
  • Loading branch information
gruenich committed Dec 17, 2023
1 parent 7f2c458 commit 7fc83cf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ParU/Source/paru_update_rowDeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,10 @@ void paru_update_rowDeg(int64_t panel_num, int64_t row_end, int64_t f,
//if (curCol < col2 && curCol >= col1) continue;
ASSERT(curCol >= col2 || curCol < col1);

if (stl_colSet.find(curCol) == stl_colSet.end())
auto insertResult = stl_colSet.insert(curCol);
// inserted to stl_colSet => insert to stl_newColSet
if (insertResult.second)
{
stl_colSet.insert(curCol);
stl_newColSet.insert(curCol);
colCount++;
}
Expand Down

0 comments on commit 7fc83cf

Please sign in to comment.