Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/FilterEngine.cpp

Issue 29391775: Issue 5013 - Improve some const-correctness (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Removed GetType() const-ness change Created March 23, 2017, 12:57 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/DefaultWebRequestCurl.cpp ('k') | src/JsValue.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/FilterEngine.cpp
===================================================================
--- a/src/FilterEngine.cpp
+++ b/src/FilterEngine.cpp
@@ -270,21 +270,20 @@ std::string FilterEngine::ContentTypeToS
return it->second;
throw std::invalid_argument("Argument is not a valid ContentType");
}
FilterEngine::ContentType FilterEngine::StringToContentType(const std::string& contentType)
{
std::string contentTypeUpper = contentType;
std::transform(contentType.begin(), contentType.end(), contentTypeUpper.begin(), ::toupper);
- for (ContentTypeMap::const_iterator it = contentTypes.begin();
- it != contentTypes.end(); it++)
+ for (const auto& contentType : contentTypes)
{
- if (it->second == contentTypeUpper)
- return it->first;
+ if (contentType.second == contentTypeUpper)
+ return contentType.first;
}
throw std::invalid_argument("Cannot convert argument to ContentType");
}
bool FilterEngine::IsFirstRun() const
{
return firstRun;
}
@@ -373,19 +372,17 @@ AdblockPlus::FilterPtr FilterEngine::Mat
AdblockPlus::FilterPtr FilterEngine::Matches(const std::string& url,
ContentTypeMask contentTypeMask,
const std::vector<std::string>& documentUrls) const
{
if (documentUrls.empty())
return CheckFilterMatch(url, contentTypeMask, "");
std::string lastDocumentUrl = documentUrls.front();
- for (std::vector<std::string>::const_iterator it = documentUrls.begin();
- it != documentUrls.end(); it++) {
- const std::string documentUrl = *it;
+ for (const auto& documentUrl : documentUrls) {
AdblockPlus::FilterPtr match = CheckFilterMatch(documentUrl,
CONTENT_TYPE_DOCUMENT,
lastDocumentUrl);
if (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCEPTION)
return match;
lastDocumentUrl = documentUrl;
}
@@ -422,18 +419,18 @@ AdblockPlus::FilterPtr FilterEngine::Che
std::vector<std::string> FilterEngine::GetElementHidingSelectors(const std::string& domain) const
{
JsValuePtr func = jsEngine->Evaluate("API.getElementHidingSelectors");
JsValueList params;
params.push_back(jsEngine->NewValue(domain));
JsValueList result = func->Call(params)->AsList();
std::vector<std::string> selectors;
- for (JsValueList::iterator it = result.begin(); it != result.end(); ++it)
- selectors.push_back((*it)->AsString());
+ for (const auto& r: result)
+ selectors.push_back(r->AsString());
return selectors;
}
JsValuePtr FilterEngine::GetPref(const std::string& pref) const
{
JsValuePtr func = jsEngine->Evaluate("API.getPref");
JsValueList params;
params.push_back(jsEngine->NewValue(pref));
« no previous file with comments | « src/DefaultWebRequestCurl.cpp ('k') | src/JsValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld