From 769d8e713def76fe0c44c9f2e99c7ed6c2826e71 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Thu, 13 Aug 2015 16:10:23 +0300 Subject: [PATCH] Eliminate repeated lookup, better variable names --- lib/suppressions.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/suppressions.cpp b/lib/suppressions.cpp index 0b533bdce..03d7efc7f 100644 --- a/lib/suppressions.cpp +++ b/lib/suppressions.cpp @@ -247,10 +247,11 @@ bool Suppressions::isSuppressed(const std::string &errorId, const std::string &f if (_suppressions["*"].isSuppressed(file, line)) return true; - if (_suppressions.find(errorId) == _suppressions.end()) + std::map::iterator suppression = _suppressions.find(errorId); + if (suppression == _suppressions.end()) return false; - return _suppressions[errorId].isSuppressed(file, line); + return suppression->second.isSuppressed(file, line); } bool Suppressions::isSuppressedLocal(const std::string &errorId, const std::string &file, unsigned int line) @@ -259,15 +260,16 @@ bool Suppressions::isSuppressedLocal(const std::string &errorId, const std::stri if (_suppressions["*"].isSuppressedLocal(file, line)) return true; - if (_suppressions.find(errorId) == _suppressions.end()) + std::map::iterator suppression = _suppressions.find(errorId); + if (suppression == _suppressions.end()) return false; - return _suppressions[errorId].isSuppressedLocal(file, line); + return suppression->second.isSuppressedLocal(file, line); } std::list Suppressions::getUnmatchedLocalSuppressions(const std::string &file, const bool unusedFunctionChecking) const { - std::list r; + std::list result; for (std::map::const_iterator i = _suppressions.begin(); i != _suppressions.end(); ++i) { if (!unusedFunctionChecking && i->first == "unusedFunction") continue; @@ -276,17 +278,17 @@ std::list Suppressions::getUnmatchedLocalSuppres if (f != i->second._files.end()) { for (std::map::const_iterator l = f->second.begin(); l != f->second.end(); ++l) { if (!l->second) { - r.push_back(SuppressionEntry(i->first, f->first, l->first)); + result.push_back(SuppressionEntry(i->first, f->first, l->first)); } } } } - return r; + return result; } std::list Suppressions::getUnmatchedGlobalSuppressions(const bool unusedFunctionChecking) const { - std::list r; + std::list result; for (std::map::const_iterator i = _suppressions.begin(); i != _suppressions.end(); ++i) { if (!unusedFunctionChecking && i->first == "unusedFunction") continue; @@ -295,10 +297,10 @@ std::list Suppressions::getUnmatchedGlobalSuppre for (std::map >::const_iterator g = i->second._globs.begin(); g != i->second._globs.end(); ++g) { for (std::map::const_iterator l = g->second.begin(); l != g->second.end(); ++l) { if (!l->second) { - r.push_back(SuppressionEntry(i->first, g->first, l->first)); + result.push_back(SuppressionEntry(i->first, g->first, l->first)); } } } } - return r; + return result; }