Bug 1131862 - mcMerge: Combine the two loops that each iterate 'products'
authorEd Morley <emorley@mozilla.com>
Tue, 24 Feb 2015 09:30:44 +0000
changeset 1507 51aa56262fc0
parent 1506 3b92d0e89f8f
child 1508 b7112fa3e56a
push id872
push useremorley@mozilla.com
push dateTue, 24 Feb 2015 23:11:31 +0000
bugs1131862
Bug 1131862 - mcMerge: Combine the two loops that each iterate 'products' Doesn't make sense to iterate through products twice. Moves the testsuiteFlagID calculation up front, then generates 'milestones' and 'hasTestsuiteFlag' as part of the same loop.
mcmerge/js/ConfigurationData.js
--- a/mcmerge/js/ConfigurationData.js
+++ b/mcmerge/js/ConfigurationData.js
@@ -40,50 +40,47 @@ var ConfigurationData = {
   },
 
 
   parseData: function CD_parseData(data, loadCallback) {
     if (!('product' in data)) {
         loadCallback();
         return;
     }
+    // Find the flag number for in-testsuite
+    if ('flag_type' in data) {
+      for (var flagNumber in data['flag_type']) {
+        if (data['flag_type'][flagNumber].name == 'in-testsuite') {
+          this.testsuiteFlagID = parseInt(flagNumber);
+          break;
+        }
+      }
+    }
     var products = data.product;
-    // Parse Milestones 
     var productMilestones = {}
     for (var product in products) {
+      // Parse Milestones
       var values = products[product].target_milestone;
       productMilestones[product] = {}
       productMilestones[product].values = values.map(UI.htmlEncode);
       var dashIndex = values.indexOf('---');
       if (dashIndex != -1) {
         if (dashIndex + 1 < values.length && this.useNext.indexOf(product) != -1)
           productMilestones[product].defaultIndex = dashIndex + 1;
         else
           productMilestones[product].defaultIndex = dashIndex;
       } else
         productMilestones[product].defaultIndex = 0;
       }
-    this.milestones = productMilestones;
 
-    // Find the flag number for in-testsuite 
-    if ('flag_type' in data) {
-      for (var flagNumber in data['flag_type']) {
-        if (data['flag_type'][flagNumber].name == 'in-testsuite') {
-          this.testsuiteFlagID = parseInt(flagNumber);
-          break;
-        }
-      }
-    }
-
-    // Find which products/components can have intestsuite set
-    if (this.testsuiteFlagID != -1) {
-      for (var product in products) {
+      // Find which products/components can have in-testsuite set
+      if (this.testsuiteFlagID != -1) {
         this.hasTestsuiteFlag[product] = {};
         for (var component in products[product].component) {
           var hasTestsuite = products[product].component[component].flag_type.indexOf(this.testsuiteFlagID) != -1;
           this.hasTestsuiteFlag[product][component] = hasTestsuite;
         }
       }
     }
-
+    this.milestones = productMilestones;
     loadCallback();
   }
 };