Bug 1337358 - Converts for(...; ...; ...) loops to use the new range-based loops in C++11 in browser/ r?fkiefer
MozReview-Commit-ID: KOTTyFtYKE8
--- a/browser/components/about/AboutRedirector.cpp
+++ b/browser/components/about/AboutRedirector.cpp
@@ -100,17 +100,16 @@ static RedirEntry kRedirMap[] = {
{ "accounts", "chrome://browser/content/aboutaccounts/aboutaccounts.xhtml",
nsIAboutModule::ALLOW_SCRIPT },
{ "reader", "chrome://global/content/reader/aboutReader.html",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::ALLOW_SCRIPT |
nsIAboutModule::URI_MUST_LOAD_IN_CHILD |
nsIAboutModule::HIDE_FROM_ABOUTABOUT },
};
-static const int kRedirTotal = ArrayLength(kRedirMap);
static nsAutoCString
GetAboutModuleName(nsIURI *aURI)
{
nsAutoCString path;
aURI->GetPath(path);
int32_t f = path.FindChar('#');
@@ -134,18 +133,18 @@ AboutRedirector::NewChannel(nsIURI* aURI
NS_ASSERTION(result, "must not be null");
nsAutoCString path = GetAboutModuleName(aURI);
nsresult rv;
nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv);
NS_ENSURE_SUCCESS(rv, rv);
- for (int i = 0; i < kRedirTotal; i++) {
- if (!strcmp(path.get(), kRedirMap[i].id)) {
+ for (auto & redir : kRedirMap) {
+ if (!strcmp(path.get(), redir.id)) {
nsAutoCString url;
if (path.EqualsLiteral("newtab")) {
// let the aboutNewTabService decide where to redirect
nsCOMPtr<nsIAboutNewTabService> aboutNewTabService =
do_GetService("@mozilla.org/browser/aboutnewtab-service;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = aboutNewTabService->GetDefaultURL(url);
@@ -158,17 +157,17 @@ AboutRedirector::NewChannel(nsIURI* aURI
NS_ENSURE_SUCCESS(rv, rv);
if (remoteEnabled) {
NS_ENSURE_ARG_POINTER(aLoadInfo);
aLoadInfo->SetVerifySignedContent(true);
}
}
// fall back to the specified url in the map
if (url.IsEmpty()) {
- url.AssignASCII(kRedirMap[i].url);
+ url.AssignASCII(redir.url);
}
nsCOMPtr<nsIChannel> tempChannel;
nsCOMPtr<nsIURI> tempURI;
rv = NS_NewURI(getter_AddRefs(tempURI), url);
NS_ENSURE_SUCCESS(rv, rv);
// If tempURI links to an external URI (i.e. something other than
@@ -204,19 +203,19 @@ AboutRedirector::NewChannel(nsIURI* aURI
NS_IMETHODIMP
AboutRedirector::GetURIFlags(nsIURI *aURI, uint32_t *result)
{
NS_ENSURE_ARG_POINTER(aURI);
nsAutoCString name = GetAboutModuleName(aURI);
- for (int i = 0; i < kRedirTotal; i++) {
- if (name.Equals(kRedirMap[i].id)) {
- *result = kRedirMap[i].flags;
+ for (auto & redir : kRedirMap) {
+ if (name.Equals(redir.id)) {
+ *result = redir.flags;
return NS_OK;
}
}
return NS_ERROR_ILLEGAL_VALUE;
}
nsresult