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: Created March 22, 2017, 3:37 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,19 @@ 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 (auto it = properties.cbegin(); it != properties.cend(); ++it)
{
- std::string header = *it;
+ const std::string & header = *it;
sergei 2017/03/22 15:44:00 please no space before & here
hub 2017/03/22 18:16:59 This is gone as I now use the range iterator. And
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,18 +71,18 @@ 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 (auto it = result.responseHeaders.cbegin();
+ it != result.responseHeaders.cend(); ++it)
{
headersObject->SetProperty(it->first, it->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