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

Unified Diff: src/WebRequestJsObject.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/Notification.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/WebRequestJsObject.cpp
===================================================================
--- a/src/WebRequestJsObject.cpp
+++ b/src/WebRequestJsObject.cpp
@@ -36,20 +36,18 @@ namespace
throw std::runtime_error("Invalid string passed as first argument to GET");
{
AdblockPlus::JsValuePtr headersObj = arguments[1];
if (!headersObj->IsObject())
throw std::runtime_error("Second argument to GET must be an object");
std::vector<std::string> properties = headersObj->GetOwnPropertyNames();
- for (std::vector<std::string>::iterator it = properties.begin();
- it != properties.end(); ++it)
+ for (const auto& header : properties)
{
- std::string header = *it;
std::string headerValue = headersObj->GetProperty(header)->AsString();
if (header.length() && headerValue.length())
headers.push_back(std::pair<std::string, std::string>(header, headerValue));
}
}
callback = arguments[2];
if (!callback->IsFunction())
@@ -72,20 +70,19 @@ namespace
AdblockPlus::JsContext context(jsEngine);
AdblockPlus::JsValuePtr resultObject = jsEngine->NewObject();
resultObject->SetProperty("status", result.status);
resultObject->SetProperty("responseStatus", result.responseStatus);
resultObject->SetProperty("responseText", result.responseText);
AdblockPlus::JsValuePtr headersObject = jsEngine->NewObject();
- for (AdblockPlus::HeaderList::iterator it = result.responseHeaders.begin();
- it != result.responseHeaders.end(); ++it)
+ for (const auto& header : result.responseHeaders)
{
- headersObject->SetProperty(it->first, it->second);
+ headersObject->SetProperty(header.first, header.second);
}
resultObject->SetProperty("responseHeaders", headersObject);
AdblockPlus::JsValueList params;
params.push_back(resultObject);
callback->Call(params);
}
« no previous file with comments | « src/Notification.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld