Skip to content

Commit 804926c

Browse files
committed
Improve performance of SuppressionsList::isSuppressed by returning as soon as a match is found.
The same is done in the other overloads of the function. By returning immediately when a match is found, heavily improve the performance of CppCheck::CppCheckLogger reportErr function in cases where a lot of errors are being suppressed.
1 parent a709c86 commit 804926c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/suppressions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,16 +475,16 @@ bool SuppressionList::isSuppressed(const SuppressionList::ErrorMessage &errmsg,
475475

476476
// TODO: handle unmatchedPolyspaceSuppression?
477477
const bool unmatchedSuppression(errmsg.errorId == "unmatchedSuppression");
478-
bool returnValue = false;
478+
479479
for (Suppression &s : mSuppressions) {
480480
if (!global && !s.isLocal())
481481
continue;
482482
if (unmatchedSuppression && s.errorId != errmsg.errorId)
483483
continue;
484484
if (s.isMatch(errmsg))
485-
returnValue = true;
485+
return true;
486486
}
487-
return returnValue;
487+
return false;
488488
}
489489

490490
bool SuppressionList::isSuppressedExplicitly(const SuppressionList::ErrorMessage &errmsg, bool global)

0 commit comments

Comments
 (0)