Bug 1337358 - Converts for(...; ...; ...) loops to use the new range-based loops in C++11 in modules/libjar/ r?froydnj draft
authorSylvestre Ledru <sledru@mozilla.com>
Tue, 07 Feb 2017 13:20:13 +0100
changeset 479860 494ca9b4c1aec28846ddc313d79fbdc9e85c7e7c
parent 479859 f54cdd43eb0d8ce39f07462d78ee062917acff7a
child 479861 7a1c92f5f05eff72369a2e6e8ca7b761bb8bfd41
push id44391
push userbmo:sledru@mozilla.com
push dateTue, 07 Feb 2017 13:22:28 +0000
reviewersfroydnj
bugs1337358
milestone54.0a1
Bug 1337358 - Converts for(...; ...; ...) loops to use the new range-based loops in C++11 in modules/libjar/ r?froydnj MozReview-Commit-ID: AZtieJz44uD
modules/libjar/nsZipArchive.cpp
--- a/modules/libjar/nsZipArchive.cpp
+++ b/modules/libjar/nsZipArchive.cpp
@@ -402,18 +402,18 @@ nsresult nsZipArchive::Test(const char *
       return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST;
     //-- don't test (synthetic) directory items
     if (currItem->IsDirectory())
       return NS_OK;
     return ExtractFile(currItem, 0, 0);
   }
 
   // test all items in archive
-  for (int i = 0; i < ZIP_TABSIZE; i++) {
-    for (currItem = mFiles[i]; currItem; currItem = currItem->next) {
+  for (auto & mFile : mFiles) {
+    for (currItem = mFile; currItem; currItem = currItem->next) {
       //-- don't test (synthetic) directory items
       if (currItem->IsDirectory())
         continue;
       nsresult rv = ExtractFile(currItem, 0, 0);
       if (rv != NS_OK)
         return rv;
     }
   }
@@ -797,19 +797,19 @@ nsresult nsZipArchive::BuildSynthetics()
 {
   if (mBuiltSynthetics)
     return NS_OK;
   mBuiltSynthetics = true;
 
 MOZ_WIN_MEM_TRY_BEGIN
   // Create synthetic entries for any missing directories.
   // Do this when all ziptable has scanned to prevent double entries.
-  for (int i = 0; i < ZIP_TABSIZE; ++i)
+  for (auto item : mFiles)
   {
-    for (nsZipItem* item = mFiles[i]; item != nullptr; item = item->next)
+    for (; item != nullptr; item = item->next)
     {
       if (item->isSynthetic)
         continue;
     
       //-- add entries for directories in the current item's path
       //-- go from end to beginning, because then we can stop trying
       //-- to create diritems if we find that the diritem we want to
       //-- create already exists