aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-01-14 14:29:27 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-01-14 14:29:27 -0800
commita03554668cf64e3f716162e049bf6ee8cbb8d3ee (patch)
treed8da11c2a7e8c3afa2b56cca8680b9d9c693e815
parentf1651fc6dc0864418039f35bfa4de577f37c2c83 (diff)
optimizer relooper by finding allInLabels only in changed labels in each iteration
-rw-r--r--src/analyzer.js18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/analyzer.js b/src/analyzer.js
index 746037a9..02ce5e6f 100644
--- a/src/analyzer.js
+++ b/src/analyzer.js
@@ -947,10 +947,12 @@ function analyzer(data, sidePass) {
});
// First, find allInLabels
- var worked = true;
- while (worked) {
- worked = false;
- labels.forEach(function(label) {
+ var more = true, nextModified, modified = set(getLabelIds(labels));
+ while (more) {
+ more = false;
+ nextModified = {};
+ for (var labelId in modified) {
+ var label = labelsDict[labelId];
var temp = label.inLabels;
label.inLabels.forEach(function(label2Id) {
temp = temp.concat(labelsDict[label2Id].allInLabels);
@@ -958,9 +960,13 @@ function analyzer(data, sidePass) {
temp = dedup(temp);
if (temp.length > label.allInLabels.length) {
label.allInLabels = temp;
- worked = true;
+ for (var i = 0; i < label.outLabels.length; i++) {
+ nextModified[label.outLabels[i]] = true;
+ }
+ more = true;
}
- });
+ }
+ modified = nextModified;
}
// Infer allOutLabels from allInLabels, they are mirror images