diff options
author | 2022-02-16 03:41:35 -0800 | |
---|---|---|
committer | 2022-02-16 03:41:35 -0800 | |
commit | 68e5b0d842929347926433c7ca914555c40a9e79 (patch) | |
tree | 85a6acd16920b266484873e132c854a1b17e46c8 | |
parent | fa6bb0fc7c29e9f27e9c74d2850b4b2179c1f1ed (diff) | |
download | bun-68e5b0d842929347926433c7ca914555c40a9e79.tar.gz bun-68e5b0d842929347926433c7ca914555c40a9e79.tar.zst bun-68e5b0d842929347926433c7ca914555c40a9e79.zip |
[js printer] slightly optimize indent / unindent
-rw-r--r-- | src/js_printer.zig | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/js_printer.zig b/src/js_printer.zig index cb3796d76..c093dbcdd 100644 --- a/src/js_printer.zig +++ b/src/js_printer.zig @@ -137,8 +137,8 @@ pub const Options = struct { // us do binary search on to figure out what line a given AST node came from // line_offset_tables: []LineOffsetTable - pub fn unindent(self: *Options) void { - self.indent = @maximum(self.indent, 1) - 1; + pub inline fn unindent(self: *Options) void { + self.indent -|= 1; } }; @@ -1553,9 +1553,7 @@ pub fn NewPrinter( p.print("{"); const props = e.properties.slice(); if (props.len > 0) { - if (!e.is_single_line) { - p.options.indent += 1; - } + p.options.indent += @as(usize, @boolToInt(!e.is_single_line)); for (props) |property, i| { if (i != 0) { @@ -2288,9 +2286,7 @@ pub fn NewPrinter( .b_array => |b| { p.print("["); if (b.items.len > 0) { - if (!b.is_single_line) { - p.options.indent += 1; - } + p.options.indent += @as(usize, @boolToInt(!b.is_single_line)); for (b.items) |*item, i| { if (i != 0) { @@ -2337,9 +2333,8 @@ pub fn NewPrinter( .b_object => |b| { p.print("{"); if (b.properties.len > 0) { - if (!b.is_single_line) { - p.options.indent += 1; - } + p.options.indent += + @as(usize, @boolToInt(!b.is_single_line)); for (b.properties) |*property, i| { if (i != 0) { |