Bug 1337358 - Converts for(...; ...; ...) loops to use the new range-based loops in C++11 in browser/ r?fkiefer draft
authorSylvestre Ledru <sledru@mozilla.com>
Tue, 07 Feb 2017 14:11:58 +0100
changeset 482828 487d56cff1b25deab7d134ad289841f1bc744d37
parent 482827 1b8462da1f392652858fbb433205ad985ee9e3dd
child 482829 0f29c4e569b6246cd59d1ec9b6abd1ae60948d1e
push id45175
push userbmo:sledru@mozilla.com
push dateMon, 13 Feb 2017 14:41:08 +0000
reviewersfkiefer
bugs1337358
milestone54.0a1
Bug 1337358 - Converts for(...; ...; ...) loops to use the new range-based loops in C++11 in browser/ r?fkiefer MozReview-Commit-ID: KOTTyFtYKE8
browser/components/about/AboutRedirector.cpp
--- 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