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); |