Bug 1340947 - Part 7: Use for-of when iterating over fixIterator in mailnews/db/gloda/. r=jorgk DONTBUILD
authorTooru Fujisawa <arai_a@mac.com>
Mon, 20 Feb 2017 12:58:22 +0900
changeset 29472 ed0f3db96eb297e17d4dd596088e435d8ad3043b
parent 29471 92d39aabf5c8a4b169764a93afa8d84f0c96a086
child 29473 4b99bbec641402df8b01f9da3bcb3b4cad181655
push id378
push userclokep@gmail.com
push dateMon, 13 Nov 2017 18:45:35 +0000
reviewersjorgk
bugs1340947
Bug 1340947 - Part 7: Use for-of when iterating over fixIterator in mailnews/db/gloda/. r=jorgk DONTBUILD
mailnews/db/gloda/modules/gloda.js
mailnews/db/gloda/modules/index_msg.js
--- a/mailnews/db/gloda/modules/gloda.js
+++ b/mailnews/db/gloda/modules/gloda.js
@@ -307,17 +307,17 @@ var Gloda = {
    *
    * @testpoint gloda.ns.getMessageCollectionForHeaders()
    */
   getMessageCollectionForHeaders: function gloda_ns_getMessagesForHeaders(
       aHeaders, aListener, aData) {
     // group the headers by the folder they are found in
     let headersByFolder = {};
     let iter;
-    for (let header in fixIterator(aHeaders)) {
+    for (let header of fixIterator(aHeaders)) {
       let folderURI = header.folder.URI;
       let headersForFolder = headersByFolder[folderURI];
       if (headersForFolder === undefined)
         headersByFolder[folderURI] = [header];
       else
         headersForFolder.push(header);
     }
 
@@ -1177,17 +1177,17 @@ var Gloda = {
 
             // skip processing this folder if we have already processed its
             //  root folder.
             if (rootFolder.URI in seenRootFolders)
               continue;
             seenRootFolders[rootFolder.URI] = true;
 
             let allFolders = rootFolder.descendants;
-            for (let folder in fixIterator(allFolders, Ci.nsIMsgFolder)) {
+            for (let folder of fixIterator(allFolders, Ci.nsIMsgFolder)) {
               let folderFlags = folder.flags;
 
               // Ignore virtual folders, non-mail folders.
               // XXX this is derived from GlodaIndexer's shouldIndexFolder.
               //  This should probably just use centralized code or the like.
               if (!(folderFlags & Ci.nsMsgFolderFlags.Mail) ||
                   (folderFlags & Ci.nsMsgFolderFlags.Virtual))
                 continue;
--- a/mailnews/db/gloda/modules/index_msg.js
+++ b/mailnews/db/gloda/modules/index_msg.js
@@ -996,17 +996,17 @@ var GlodaMsgIndexer = {
   _worker_indexingSweep: function* gloda_worker_indexingSweep(aJob) {
     if (!aJob.mappedFolders) {
       // Walk the folders and make sure all the folders we would want to index
       //  are mapped.  Build up a list of GlodaFolders as we go, so that we can
       //  sort them by their indexing priority.
       let foldersToProcess = aJob.foldersToProcess = [];
 
       let allFolders = MailServices.accounts.allFolders;
-      for (let folder in fixIterator(allFolders, Ci.nsIMsgFolder)) {
+      for (let folder of fixIterator(allFolders, Ci.nsIMsgFolder)) {
         if (this.shouldIndexFolder(folder))
           foldersToProcess.push(Gloda.getFolderForFolder(folder));
       }
 
       // sort the folders by priority (descending)
       foldersToProcess.sort(function (a, b) {
         return b.indexingPriority - a.indexingPriority;
       });
@@ -1357,17 +1357,17 @@ var GlodaMsgIndexer = {
     //  everyone in one go in a filthy context because if we have to terminate
     //  indexing before we quit, we don't want to have to re-index messages next
     //  time.  (This could even lead to never completing indexing in a
     //  pathological situation.)
     let glodaFolder = GlodaDatastore._mapFolder(this._indexingFolder);
     if (glodaFolder.dirtyStatus == glodaFolder.kFolderFilthy) {
       this._indexerGetEnumerator(this.kEnumIndexedMsgs, true);
       let count = 0;
-      for (let msgHdr in fixIterator(this._indexingEnumerator, nsIMsgDBHdr)) {
+      for (let msgHdr of fixIterator(this._indexingEnumerator, nsIMsgDBHdr)) {
         // we still need to avoid locking up the UI, pause periodically...
         if (++count % HEADER_CHECK_SYNC_BLOCK_SIZE == 0)
           yield this.kWorkSync;
 
         if (count % HEADER_CHECK_GC_BLOCK_SIZE == 0)
           GlodaUtils.considerHeaderBasedGC(HEADER_CHECK_GC_BLOCK_SIZE);
 
         let glodaMessageId = msgHdr.getUint32Property(
@@ -1415,17 +1415,17 @@ var GlodaMsgIndexer = {
     aJob.goal = numMessagesToIndex;
 
     if (numMessagesToIndex > 0) {
       // We used up the iterator, get a new one.
       this._indexerGetEnumerator(enumeratorType);
 
       // Pass 2: index the messages.
       let count = 0;
-      for (let msgHdr in fixIterator(this._indexingEnumerator, nsIMsgDBHdr)) {
+      for (let msgHdr of fixIterator(this._indexingEnumerator, nsIMsgDBHdr)) {
         // per above, we want to periodically release control while doing all
         // this header traversal/investigation.
         if (++count % HEADER_CHECK_SYNC_BLOCK_SIZE == 0)
           yield this.kWorkSync;
 
         if (count % HEADER_CHECK_GC_BLOCK_SIZE == 0)
           GlodaUtils.considerHeaderBasedGC(HEADER_CHECK_GC_BLOCK_SIZE);
 
@@ -1882,34 +1882,34 @@ var GlodaMsgIndexer = {
    *  and have an accurate estimate of the number of folders that need to be
    *  indexed.  (We previously queued accounts rather than immediately
    *  walking their list of folders.)
    */
   indexEverything: function glodaIndexEverything() {
     this._log.info("Queueing all accounts for indexing.");
 
     GlodaDatastore._beginTransaction();
-    for (let account in fixIterator(MailServices.accounts.accounts,
+    for (let account of fixIterator(MailServices.accounts.accounts,
                                     Ci.nsIMsgAccount)) {
       this.indexAccount(account);
     }
     GlodaDatastore._commitTransaction();
   },
 
   /**
    * Queue all of the folders belonging to an account for indexing.
    */
   indexAccount: function glodaIndexAccount(aAccount) {
     let rootFolder = aAccount.incomingServer.rootFolder;
     if (rootFolder instanceof Ci.nsIMsgFolder) {
       this._log.info("Queueing account folders for indexing: " + aAccount.key);
 
       let allFolders = rootFolder.descendants;
       let folderJobs = [];
-      for (let folder in fixIterator(allFolders, Ci.nsIMsgFolder)) {
+      for (let folder of fixIterator(allFolders, Ci.nsIMsgFolder)) {
         if (this.shouldIndexFolder(folder))
           GlodaIndexer.indexJob(
             new IndexingJob("folder", GlodaDatastore._mapFolder(folder).id));
       }
     }
     else {
       this._log.info("Skipping Account, root folder not nsIMsgFolder");
     }
@@ -2048,17 +2048,17 @@ var GlodaMsgIndexer = {
    *     after the first notification, we would likely just mistakenly treat
    *     the msgsClassified notification as something dirtying, so it would
    *     still work out...)
    */
   _reindexChangedMessages: function gloda_indexer_reindexChangedMessage(
                                       aMsgHdrs, aDirtyingEvent) {
     let glodaIdsNeedingDeletion = null;
     let messageKeyChangedIds = null, messageKeyChangedNewKeys = null;
-    for (let msgHdr in fixIterator(aMsgHdrs, nsIMsgDBHdr)) {
+    for (let msgHdr of fixIterator(aMsgHdrs, nsIMsgDBHdr)) {
       // -- Index this folder?
       let msgFolder = msgHdr.folder;
       if (!this.shouldIndexFolder(msgFolder)) {
         continue;
       }
       // -- Ignore messages in filthy folders!
       // A filthy folder can only be processed by an indexing sweep, and at
       //  that point the message will get indexed.
@@ -2321,17 +2321,17 @@ var GlodaMsgIndexer = {
           //  none of the gloda-id's are valid (and so we certainly don't want
           //  to try and use them as a basis for updating message keys.)
           let srcMsgFolder = aSrcMsgHdrs.queryElementAt(0, nsIMsgDBHdr).folder;
           if (!this.indexer.shouldIndexFolder(srcMsgFolder) ||
               (GlodaDatastore._mapFolder(srcMsgFolder).dirtyStatus ==
                  GlodaFolder.prototype.kFolderFilthy)) {
             // Local case, just modify the destination headers directly.
             if (aDestMsgHdrs) {
-              for (let destMsgHdr in fixIterator(aDestMsgHdrs, nsIMsgDBHdr)) {
+              for (let destMsgHdr of fixIterator(aDestMsgHdrs, nsIMsgDBHdr)) {
                 // zero it out if it exists
                 // (no need to deal with pending commit issues here; a filthy
                 //  folder by definition has nothing indexed in it.)
                 let glodaId = destMsgHdr.getUint32Property(
                                 GLODA_MESSAGE_ID_PROPERTY);
                 if (glodaId)
                   destMsgHdr.setUint32Property(GLODA_MESSAGE_ID_PROPERTY,
                                                0);
@@ -2353,17 +2353,17 @@ var GlodaMsgIndexer = {
                 destDb = aDestFolder.msgDatabase;
               } catch (ex) {
                 this.indexer._log.warn("Destination database for " +
                                        aDestFolder.prettyName +
                                        " not ready on IMAP move." +
                                        " Gloda corruption possible.");
                 return;
               }
-              for (let srcMsgHdr in fixIterator(aSrcMsgHdrs, nsIMsgDBHdr)) {
+              for (let srcMsgHdr of fixIterator(aSrcMsgHdrs, nsIMsgDBHdr)) {
                 // zero it out if it exists
                 // (no need to deal with pending commit issues here; a filthy
                 //  folder by definition has nothing indexed in it.)
                 let glodaId = srcMsgHdr.getUint32Property(
                                 GLODA_MESSAGE_ID_PROPERTY);
                 if (glodaId)
                   destDb.setUint32AttributeOnPendingHdr(
                     srcMsgHdr, GLODA_MESSAGE_ID_PROPERTY, 0);
@@ -2468,17 +2468,17 @@ var GlodaMsgIndexer = {
             //  message added events will cause that to happen.
           }
         }
         // ---- Copy case
         else {
           // -- Do not propagate gloda-id's for copies
           // (Only applies if we have the destination header, which means local)
           if (aDestMsgHdrs) {
-            for (let destMsgHdr in fixIterator(aDestMsgHdrs, nsIMsgDBHdr)) {
+            for (let destMsgHdr of fixIterator(aDestMsgHdrs, nsIMsgDBHdr)) {
               let glodaId = destMsgHdr.getUint32Property(
                 GLODA_MESSAGE_ID_PROPERTY);
               if (glodaId)
                 destMsgHdr.setUint32Property(GLODA_MESSAGE_ID_PROPERTY, 0);
             }
           }
 
           // mark the folder as dirty; we'll get to it later.
@@ -2578,17 +2578,17 @@ var GlodaMsgIndexer = {
           }
         };
 
         let descendentFolders = aFolder.descendants;
         // (the order of operations does not matter; child, non-child, whatever.)
         // delete the parent
         delFunc(aFolder, this.indexer);
         // delete all its descendents
-        for (let folder in fixIterator(descendentFolders, Ci.nsIMsgFolder)) {
+        for (let folder of fixIterator(descendentFolders, Ci.nsIMsgFolder)) {
           delFunc(folder, this.indexer);
         }
 
         this.indexer.pendingDeletions = true;
       } catch (ex) {
         this.indexer._log.error("Problem encountered during folder deletion" +
           ": " + ex + "\n\n" + ex.stack + "\n\n");
       }
@@ -2631,30 +2631,30 @@ var GlodaMsgIndexer = {
       let newFolder = MailUtils.getFolderForURI(aNewURI);
       let specialFolderFlags = Ci.nsMsgFolderFlags.Trash | Ci.nsMsgFolderFlags.Junk;
       if (newFolder.isSpecialFolder(specialFolderFlags, true)) {
         let descendentFolders = newFolder.descendants;
 
         // First thing to do: make sure we don't index the resulting folder and
         //  its descendents.
         GlodaMsgIndexer.resetFolderIndexingPriority(newFolder);
-        for (let folder in fixIterator(descendentFolders, Ci.nsIMsgFolder)) {
+        for (let folder of fixIterator(descendentFolders, Ci.nsIMsgFolder)) {
           GlodaMsgIndexer.resetFolderIndexingPriority(folder);
         }
 
         // Remove from the index messages from the original folder
         this.folderDeleted(aOrigFolder);
       } else {
         let descendentFolders = aOrigFolder.descendants;
 
         let origURI = aOrigFolder.URI;
         // this rename is straightforward.
         GlodaDatastore.renameFolder(aOrigFolder, aNewURI);
 
-        for (let folder in fixIterator(descendentFolders, Ci.nsIMsgFolder)) {
+        for (let folder of fixIterator(descendentFolders, Ci.nsIMsgFolder)) {
           let oldSubURI = folder.URI;
           // mangle a new URI from the old URI.  we could also try and do a
           //  parallel traversal of the new folder hierarchy, but that seems like
           //  more work.
           let newSubURI = aNewURI + oldSubURI.substring(origURI.length);
           this.indexer._datastore.renameFolder(oldSubURI, newSubURI);
         }