File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -420,7 +420,7 @@ SuppressionList::Suppression::Result SuppressionList::Suppression::isSuppressed(
420420 if (!thisAndNextLine || lineNumber + 1 != errmsg.lineNumber )
421421 return Result::None;
422422 }
423- if (!fileName.empty () && !PathMatch::match (fileName, errmsg.getFileName ()))
423+ if (!fileName.empty () && !isFileNameMatch ( errmsg.getFileName ()))
424424 return Result::None;
425425 if (hash > 0 && hash != errmsg.hash )
426426 return Result::Checked;
@@ -453,6 +453,21 @@ SuppressionList::Suppression::Result SuppressionList::Suppression::isSuppressed(
453453 return Result::Matched;
454454}
455455
456+ bool SuppressionList::Suppression::isFileNameMatch (const std::string &errorFileName) const
457+ {
458+ const auto it = mFileNameMatchCache .find (errorFileName);
459+ if (it != mFileNameMatchCache .end ())
460+ return it->second ;
461+
462+ const bool isMatch = PathMatch::match (fileName, errorFileName);
463+
464+ if (mFileNameMatchCache .size () >= FileNameMatchCacheMaxEntries)
465+ mFileNameMatchCache .clear ();
466+
467+ mFileNameMatchCache .emplace (errorFileName, isMatch);
468+ return isMatch;
469+ }
470+
456471bool SuppressionList::Suppression::isMatch (const SuppressionList::ErrorMessage &errmsg)
457472{
458473 switch (isSuppressed (errmsg)) {
Original file line number Diff line number Diff line change @@ -168,6 +168,12 @@ class CPPCHECKLIB SuppressionList {
168168 bool isPolyspace{};
169169
170170 enum : std::int8_t { NO_LINE = -1 };
171+
172+ private:
173+ bool isFileNameMatch (const std::string &errorFileName) const ;
174+
175+ static constexpr std::size_t FileNameMatchCacheMaxEntries = 256 ;
176+ mutable std::map<std::string, bool > mFileNameMatchCache ;
171177 };
172178
173179 /* *
You can’t perform that action at this time.
0 commit comments