Remove an error check after calling action code

The error check was useful when actions could have returned |null| to
trigger a match failure. This is no longer supported so the check isn't
needed anymore.

Speed impact
------------
Before:     1022.70 kB/s
After:      1035.45 kB/s
Difference: 1.24%

Size impact
-----------
Before:     975434 b
After:      931540 b
Difference: -4.50%

(Measured by /tools/impact with Node.js v0.6.18 on x86_64 GNU/Linux.)
redux
David Majda 11 years ago
parent 2f2152204a
commit e15c57066c

@ -351,7 +351,7 @@ module.exports = function(ast, options) {
),
[]
),
buildCondition([op.IF_ERROR], [op.NIP_CURR_POS], [op.NIP])
[op.NIP]
)
: expressionCode;
},
@ -400,7 +400,7 @@ module.exports = function(ast, options) {
context.env,
context.sp
),
buildCondition([op.IF_ERROR], [op.NIP_CURR_POS], [op.NIP])
[op.NIP]
);
} else {
return buildSequence([op.WRAP, node.elements.length], [op.NIP]);

@ -534,12 +534,7 @@ module.exports = (function() {
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c3(s2, s3);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -569,12 +564,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c4(s1);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -609,12 +599,7 @@ module.exports = (function() {
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c5(s1, s2, s4);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -682,12 +667,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c6(s1, s2);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -715,12 +695,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c7(s1, s2);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -741,12 +716,7 @@ module.exports = (function() {
peg$reportedPos = s0;
s1 = peg$c8(s1);
}
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
}
return s0;
@ -764,12 +734,7 @@ module.exports = (function() {
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c9(s1, s3);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -799,12 +764,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c10(s2);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -821,12 +781,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c11(s2);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -843,12 +798,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c12(s2);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -865,12 +815,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c13(s2);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -887,12 +832,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c14(s2);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -922,12 +862,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c15(s1);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -944,12 +879,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c16(s1);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -966,12 +896,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c17(s1);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1025,12 +950,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c19(s1);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1050,12 +970,7 @@ module.exports = (function() {
peg$reportedPos = s0;
s1 = peg$c20();
}
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parselparen();
@ -1066,12 +981,7 @@ module.exports = (function() {
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c21(s2);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1103,12 +1013,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c23(s1);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1229,12 +1134,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c32();
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1263,12 +1163,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c35();
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1297,12 +1192,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c38();
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1331,12 +1221,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c41();
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1365,12 +1250,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c44();
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1399,12 +1279,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c47();
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1433,12 +1308,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c50();
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1467,12 +1337,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c53();
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1501,12 +1366,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c56();
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1535,12 +1395,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c59();
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1569,12 +1424,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c62();
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1603,12 +1453,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c65();
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1637,12 +1482,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c68();
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1723,12 +1563,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c72(s1);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1771,12 +1606,7 @@ module.exports = (function() {
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c76(s1, s2);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1812,12 +1642,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c78(s1);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1864,12 +1689,7 @@ module.exports = (function() {
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c81(s2);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1952,12 +1772,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c85(s2);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -1999,12 +1814,7 @@ module.exports = (function() {
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c81(s2);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -2087,12 +1897,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c85(s2);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -2165,12 +1970,7 @@ module.exports = (function() {
if (s6 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c95(s2, s3, s5);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -2222,12 +2022,7 @@ module.exports = (function() {
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c98(s1, s3);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -2253,12 +2048,7 @@ module.exports = (function() {
peg$reportedPos = s0;
s1 = peg$c99(s1);
}
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
return s0;
}
@ -2329,12 +2119,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c85(s2);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -2401,12 +2186,7 @@ module.exports = (function() {
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c104(s3);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -2448,12 +2228,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c107();
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -2501,12 +2276,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c110(s2);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -2566,12 +2336,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c110(s2);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
@ -2600,12 +2365,7 @@ module.exports = (function() {
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c113(s2);
if (s1 === peg$FAILED) {
peg$currPos = s0;
s0 = s1;
} else {
s0 = s1;
}
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;

@ -94,9 +94,7 @@ describe("compiler pass |generateBytecode|", function() {
12, 6, 0, // IF_NOT_ERROR
21, 1, // * REPORT_SAVED_POS
23, 1, 1, 0, // CALL
11, 1, 1, // IF_ERROR
6, // * NIP_CURR_POS
5 // * NIP
5 // NIP
]));
});
@ -118,9 +116,7 @@ describe("compiler pass |generateBytecode|", function() {
12, 7, 0, // IF_NOT_ERROR
21, 1, // * REPORT_SAVED_POS
23, 2, 1, 1, 0, // CALL
11, 1, 1, // IF_ERROR
6, // * NIP_CURR_POS
5 // * NIP
5 // NIP
]));
});
@ -139,16 +135,14 @@ describe("compiler pass |generateBytecode|", function() {
expect(pass).toChangeAST(grammar, bytecodeDetails([
1, // PUSH_CURR_POS
15, 1, 2, 2, 19, 1, 20, 2, // <elements[0]>
12, 46, 4, // IF_NOT_ERROR
12, 42, 4, // IF_NOT_ERROR
15, 3, 2, 2, 19, 3, 20, 4, // * <elements[1]>
12, 30, 5, // IF_NOT_ERROR
12, 26, 5, // IF_NOT_ERROR
15, 5, 2, 2, 19, 5, 20, 6, // * <elements[2]>
12, 14, 5, // IF_NOT_ERROR
12, 10, 5, // IF_NOT_ERROR
21, 3, // * REPORT_SAVED_POS
23, 7, 3, 3, 2, 1, 0, // CALL
11, 1, 1, // IF_ERROR
6, // * NIP_CURR_POS
5, // * NIP
5, // NIP
4, 3, // * POP_N
3, // POP_CURR_POS
0, 0, // PUSH

Loading…
Cancel
Save