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.
--- 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();
}
};