Bug 1337358 - Converts for(...; ...; ...) loops to use the new range-based loops in C++11 in modules/libjar/ r=froydnj
authorSylvestre Ledru <sledru@mozilla.com>
Wed, 08 Feb 2017 12:06:26 +0100
changeset 342524 50e0a1c9d2cec3276c7435809872f052f615f987
parent 342523 7e5f3ebcd77c71796a6ab52186b950f78dea7b78
child 342525 5fc40ff287463fbd49defde5732a21aa814fc865
push id31357
push userkwierso@gmail.com
push dateTue, 14 Feb 2017 00:49:21 +0000
treeherdermozilla-central@bca082441767 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1337358
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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* item : mFiles) {
+    for (currItem = item; 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,23 +797,23 @@ 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
       //-- start just before the last char so as to not add the item
       //-- twice if it's a directory
       uint16_t namelen = item->nameLength;
       MOZ_ASSERT(namelen > 0, "Attempt to build synthetic for zero-length entry name!");