Bug 1514483 - [mail] simplified loops for Services.catMan.enumerateCategory; r=aceman
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Sat, 15 Dec 2018 15:41:26 +0200
changeset 33155 8de5f19ac58c
parent 33154 832d6196becb
child 33156 33c3ec8edd93
push id2368
push userclokep@gmail.com
push dateMon, 28 Jan 2019 21:12:50 +0000
treeherdercomm-beta@56d23c07d815 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman
bugs1514483
Bug 1514483 - [mail] simplified loops for Services.catMan.enumerateCategory; r=aceman Paces affected: - Options | Attachments | Outgoing | Add... - Account manager - extension added panes - custom mime encoders [testing covered by unit test]
mail/components/cloudfile/cloudFileAccounts.js
mail/test/mozmill/cloudfile/test-cloudfile-add-account-dialog.js
mailnews/base/prefs/content/AccountManager.js
mailnews/mime/src/jsmime.jsm
--- a/mail/components/cloudfile/cloudFileAccounts.js
+++ b/mail/components/cloudfile/cloudFileAccounts.js
@@ -188,20 +188,19 @@ var cloudFileAccounts = new class extend
     }
   }
 
   * enumerateProviders() {
     for (let [type, provider] of this._providers.entries()) {
       yield [type, provider];
     }
 
-    for (let entry of fixIterator(Services.catMan.enumerateCategory(CATEGORY),
-                                  Ci.nsISupportsCString)) {
-      let provider = this.getProviderForType(entry.data);
-      yield [entry.data, provider];
+    for (let {data} of Services.catMan.enumerateCategory(CATEGORY)) {
+      let provider = this.getProviderForType(data);
+      yield [data, provider];
     }
   }
 
   getAccount(aKey) {
     let type = Services.prefs.getCharPref(ACCOUNT_ROOT + aKey + ".type");
     return this._getInitedProviderForType(aKey, type);
   }
 
--- a/mail/test/mozmill/cloudfile/test-cloudfile-add-account-dialog.js
+++ b/mail/test/mozmill/cloudfile/test-cloudfile-add-account-dialog.js
@@ -31,18 +31,17 @@ var gOldProviders = {};
 var gOldWeTransferProvider = null;
 
 function setupModule(module) {
   for (let lib of MODULE_REQUIRES) {
     collector.getModule(lib).installInto(module);
   }
 
   // Save the old providers...
-  for (let entry of fixIterator(Services.catMan.enumerateCategory(kCategory),
-                                Ci.nsISupportsCString)) {
+  for (let entry of Services.catMan.enumerateCategory(kCategory)) {
     let value = Services.catMan.getCategoryEntry(kCategory, entry.data);
     gOldProviders[entry] = value;
   }
 
   // Clear out the old entries
   Services.catMan.deleteCategory(kCategory);
   gOldWeTransferProvider = cloudFileAccounts.getProviderForType(
     "ext-wetransfer@extensions.thunderbird.net"
--- a/mailnews/base/prefs/content/AccountManager.js
+++ b/mailnews/base/prefs/content/AccountManager.js
@@ -1563,34 +1563,31 @@ var gAccountTree = {
         let diskspace = server.supportsDiskSpace;
         if (server.offlineSupportLevel >= 10 && diskspace)
           panelsToKeep.push(panels[2]);
         else if (diskspace)
           panelsToKeep.push(panels[3]);
 
         // extensions
         const CATEGORY = "mailnews-accountmanager-extensions";
-        let catEnum = Services.catMan.enumerateCategory(CATEGORY);
-        while (catEnum.hasMoreElements()) {
-          let entryName = null;
+        for (let {data} of Services.catMan.enumerateCategory(CATEGORY)) {
           try {
-            entryName = catEnum.getNext().QueryInterface(Ci.nsISupportsCString).data;
-            let svc = Cc[Services.catMan.getCategoryEntry(CATEGORY, entryName)]
+            let svc = Cc[Services.catMan.getCategoryEntry(CATEGORY, data)]
                         .getService(Ci.nsIMsgAccountManagerExtension);
             if (svc.showPanel(server)) {
               let bundleName = "chrome://" + svc.chromePackageName +
                                "/locale/am-" + svc.name + ".properties";
               let bundle = Services.strings.createBundle(bundleName);
               let title = bundle.GetStringFromName("prefPanel-" + svc.name);
               panelsToKeep.push({string: title, src: "am-" + svc.name + ".xul"});
             }
           } catch(e) {
             // Fetching of this extension panel failed so do not show it,
             // just log error.
-            let extName = entryName || "(unknown)";
+            let extName = data || "(unknown)";
             Cu.reportError("Error accessing panel from extension '" +
                            extName + "': " + e);
           }
         }
         amChrome = server.accountManagerChrome;
       } catch(e) {
         // Show only a placeholder in the account list saying this account
         // is broken, with no child panels.
--- a/mailnews/mime/src/jsmime.jsm
+++ b/mailnews/mime/src/jsmime.jsm
@@ -59,16 +59,12 @@ Services.obs.addObserver(function (subje
   subject = subject.QueryInterface(Ci.nsISupportsCString)
                    .data;
   if (data == CATEGORY_NAME) {
     let url = Services.catMan.getCategoryEntry(CATEGORY_NAME, subject);
     Services.scriptloader.loadSubScript(url, {}, "UTF-8");
   }
 }, "xpcom-category-entry-added");
 
-var entries = Services.catMan.enumerateCategory(CATEGORY_NAME);
-while (entries.hasMoreElements()) {
-  let string = entries.getNext()
-                      .QueryInterface(Ci.nsISupportsCString)
-                      .data;
-  let url = Services.catMan.getCategoryEntry(CATEGORY_NAME, string);
+for (let {data} of Services.catMan.enumerateCategory(CATEGORY_NAME)) {
+  let url = Services.catMan.getCategoryEntry(CATEGORY_NAME, data);
   Services.scriptloader.loadSubScript(url, {}, "UTF-8");
 }