aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-09-23 16:53:48 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-09-23 16:53:48 -0700
commitca912fdf04149416e5762a13c4a25e69f481a4d9 (patch)
tree43b10aba02bd165e28562e42c55699ffa773560c
parent6e8e67dcd1a82b4beae132528e6e7b08d14edd09 (diff)
sort target labels in switches so output is consistently ordered
-rw-r--r--src/jsifier.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 01546b05..96cb8d9a 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -1114,7 +1114,8 @@ function JSify(data, functionsOnly, givenFunctions) {
if (!useIfs) {
ret += 'switch(' + signedIdent + ') {\n';
}
- for (var targetLabel in targetLabels) {
+ // process target labels, sorting them so output is consistently ordered
+ keys(targetLabels).sort().forEach(function(targetLabel) {
if (!first && useIfs) {
ret += 'else ';
} else {
@@ -1142,7 +1143,7 @@ function JSify(data, functionsOnly, givenFunctions) {
labelJS: phiSet
});
}
- }
+ });
var phiSet = item.defaultLabelJS = getPhiSetsForLabel(phiSets, item.defaultLabel);
if (useIfs) {
if (item.switchLabels.length > 0) ret += 'else {\n';