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 479859 f54cdd43eb0d8ce39f07462d78ee062917acff7a
parent 479858 2e22694945b721a18dd2fbb1d5db57b4b4fbe9c0
child 479860 494ca9b4c1aec28846ddc313d79fbdc9e85c7e7c
push id44391
push userbmo:sledru@mozilla.com
push dateTue, 07 Feb 2017 13:22:28 +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