improve performance (#3020)

- replace `find_if()` with `all()` wherever possible
- move ESTree-specific logic out of `figure_out_scope()`
This commit is contained in:
Alex Lam S.L
2018-03-23 03:43:52 +08:00
committed by GitHub
parent d1c6bb8c7c
commit 49bfc6b555
5 changed files with 30 additions and 26 deletions

View File

@@ -969,7 +969,9 @@ function parse($TEXT, options) {
function labeled_statement() {
var label = as_symbol(AST_Label);
if (find_if(function(l){ return l.name == label.name }, S.labels)) {
if (!all(S.labels, function(l) {
return l.name != label.name;
})) {
// ECMA-262, 12.12: An ECMAScript program is considered
// syntactically incorrect if it contains a
// LabelledStatement that is enclosed by a