Fast path for newline processing.

This commit is contained in:
Logan Smyth 2016-04-17 01:49:50 -07:00
parent e7796b45c9
commit dc92a16e7f

View File

@ -211,10 +211,20 @@ export default class Printer extends Buffer {
}
_printNewline(leading, node, parent, opts) {
// Fast path since 'this.newline' does nothing when not tracking lines.
if (this.format.retainLines || this.format.compact) return;
if (!opts.statement && !n.isUserWhitespacable(node, parent)) {
return;
}
// Fast path for concise since 'this.newline' just inserts a space when
// concise formatting is in use.
if (this.format.concise) {
this.space();
return;
}
let lines = 0;
if (node.start != null && !node._ignoreUserWhitespace && this.tokens.length) {