speed up has_parens() (take 2) (#3052)

fixes #3050
This commit is contained in:
Alex Lam S.L
2018-04-05 04:12:04 +08:00
committed by GitHub
parent 81603ecd15
commit b5bab254ce
2 changed files with 24 additions and 3 deletions

View File

@@ -197,6 +197,7 @@ function OutputStream(options) {
/* -----[ beautification/minification ]----- */
var has_parens = false;
var might_need_space = false;
var might_need_semicolon = false;
var might_add_newline = 0;
@@ -340,6 +341,7 @@ function OutputStream(options) {
}
OUTPUT += str;
has_parens = str[str.length - 1] == "(";
current_pos += str.length;
var a = str.split(/\r?\n/), n = a.length - 1;
current_line += n;
@@ -576,7 +578,7 @@ function OutputStream(options) {
indentation : function() { return indentation },
current_width : function() { return current_col - indentation },
should_break : function() { return options.width && this.current_width() >= options.width },
has_parens : function() { return OUTPUT[OUTPUT.length - 1] == "(" },
has_parens : function() { return has_parens },
newline : newline,
print : print,
space : space,