From c4b5d506d1f07c98e072bae627315a25ea694161 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 14 Jan 2025 20:54:52 -0800 Subject: [PATCH] zig: else branch is implicitly void --- src/bun.js/api/Timer.zig | 3 +-- src/bun.js/api/bun/dns_resolver.zig | 2 +- src/bun.js/api/bun/process.zig | 4 +--- src/bun.js/api/bun/subprocess.zig | 2 +- src/bun.js/api/server.zig | 2 +- src/bun.js/event_loop.zig | 6 +++--- src/bun.js/javascript.zig | 8 ++++---- src/bun.js/node/node_fs.zig | 2 +- src/bun.js/webcore.zig | 3 +-- src/cli/bunx_command.zig | 2 +- src/cli/create_command.zig | 20 ++++++++------------ src/cli/filter_run.zig | 2 +- src/cli/init_command.zig | 3 +-- src/cli/publish_command.zig | 7 +++---- src/cli/run_command.zig | 4 ++-- src/cli/upgrade_command.zig | 2 +- src/css/css_parser.zig | 4 ++-- src/hive_array.zig | 2 +- src/install/install.zig | 12 ++++++------ src/install/lifecycle_script_runner.zig | 8 +++----- src/install/lockfile.zig | 8 ++++---- src/install/npm.zig | 2 +- src/js_lexer.zig | 5 ++--- src/js_parser.zig | 9 ++++----- src/json_parser.zig | 8 ++------ src/open.zig | 2 +- src/patch.zig | 2 +- src/shell/subproc.zig | 2 +- src/string.zig | 2 +- src/sys.zig | 2 +- 30 files changed, 61 insertions(+), 79 deletions(-) diff --git a/src/bun.js/api/Timer.zig b/src/bun.js/api/Timer.zig index 309cfdea2d6f4c..2e52553ce719af 100644 --- a/src/bun.js/api/Timer.zig +++ b/src/bun.js/api/Timer.zig @@ -32,8 +32,7 @@ pub const All = struct { .context = {}, }, active_timer_count: i32 = 0, - uv_timer: if (Environment.isWindows) uv.Timer else void = - if (Environment.isWindows) std.mem.zeroes(uv.Timer) else {}, + uv_timer: if (Environment.isWindows) uv.Timer else void = if (Environment.isWindows) std.mem.zeroes(uv.Timer), // We split up the map here to avoid storing an extra "repeat" boolean maps: struct { diff --git a/src/bun.js/api/bun/dns_resolver.zig b/src/bun.js/api/bun/dns_resolver.zig index 1ae5ccd9262333..0119d828ff7fab 100644 --- a/src/bun.js/api/bun/dns_resolver.zig +++ b/src/bun.js/api/bun/dns_resolver.zig @@ -1248,7 +1248,7 @@ pub const InternalDNS = struct { valid: bool = true, - libinfo: if (Environment.isMac) MacAsyncDNS else void = if (Environment.isMac) .{} else {}, + libinfo: if (Environment.isMac) MacAsyncDNS else void = if (Environment.isMac) .{}, pub fn isExpired(this: *Request, timestamp_to_store: *u32) bool { if (this.refcount > 0 or this.result == null) { diff --git a/src/bun.js/api/bun/process.zig b/src/bun.js/api/bun/process.zig index 0c353110daf6a5..08cba669ea3713 100644 --- a/src/bun.js/api/bun/process.zig +++ b/src/bun.js/api/bun/process.zig @@ -1799,9 +1799,7 @@ pub const sync = struct { .use_execve_on_macos = this.use_execve_on_macos, .stream = false, .argv0 = this.argv0, - .windows = if (Environment.isWindows) - this.windows - else {}, + .windows = if (Environment.isWindows) this.windows, }; } }; diff --git a/src/bun.js/api/bun/subprocess.zig b/src/bun.js/api/bun/subprocess.zig index f638466a7d9ef3..e41dbfc5ce694d 100644 --- a/src/bun.js/api/bun/subprocess.zig +++ b/src/bun.js/api/bun/subprocess.zig @@ -2137,7 +2137,7 @@ pub const Subprocess = struct { .hide_window = windows_hide, .verbatim_arguments = windows_verbatim_arguments, .loop = JSC.EventLoopHandle.init(jsc_vm), - } else {}, + }, }; var spawned = switch (bun.spawn.spawnProcess( diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index a841498d3ec8bd..7504452e552e09 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -1659,7 +1659,7 @@ fn NewFlags(comptime debug_mode: bool) type { is_waiting_for_request_body: bool = false, /// Used in renderMissing in debug mode to show the user an HTML page /// Used to avoid looking at the uws.Request struct after it's been freed - is_web_browser_navigation: if (debug_mode) bool else void = if (debug_mode) false else {}, + is_web_browser_navigation: if (debug_mode) bool else void = if (debug_mode) false, has_written_status: bool = false, response_protected: bool = false, aborted: bool = false, diff --git a/src/bun.js/event_loop.zig b/src/bun.js/event_loop.zig index f1d8deb3246860..48e23a010bc5e0 100644 --- a/src/bun.js/event_loop.zig +++ b/src/bun.js/event_loop.zig @@ -785,13 +785,13 @@ pub const EventLoop = struct { waker: ?Waker = null, forever_timer: ?*uws.Timer = null, deferred_tasks: DeferredTaskQueue = .{}, - uws_loop: if (Environment.isWindows) ?*uws.Loop else void = if (Environment.isWindows) null else {}, + uws_loop: if (Environment.isWindows) ?*uws.Loop else void = if (Environment.isWindows) null, debug: Debug = .{}, entered_event_loop_count: isize = 0, concurrent_ref: std.atomic.Value(i32) = std.atomic.Value(i32).init(0), - signal_handler: if (Environment.isPosix) ?*PosixSignalHandle else void = if (Environment.isPosix) null else {}, + signal_handler: if (Environment.isPosix) ?*PosixSignalHandle else void = if (Environment.isPosix) null, pub export fn Bun__ensureSignalHandler() void { if (Environment.isPosix) { @@ -1426,7 +1426,7 @@ pub const EventLoop = struct { if (loop.isActive()) { this.processGCTimer(); - var event_loop_sleep_timer = if (comptime Environment.isDebug) std.time.Timer.start() catch unreachable else {}; + var event_loop_sleep_timer = if (comptime Environment.isDebug) std.time.Timer.start() catch unreachable; // for the printer, this is defined: var timespec: bun.timespec = if (Environment.isDebug) .{ .sec = 0, .nsec = 0 } else undefined; loop.tickWithTimeout(if (ctx.timer.getTimeout(×pec)) ×pec else null); diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index b56003968a8f8e..ed1341fe03857e 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -1916,7 +1916,7 @@ pub const VirtualMachine = struct { .ref_strings = JSC.RefString.Map.init(allocator), .ref_strings_mutex = .{}, .standalone_module_graph = opts.graph.?, - .debug_thread_id = if (Environment.allow_assert) std.Thread.getCurrentId() else {}, + .debug_thread_id = if (Environment.allow_assert) std.Thread.getCurrentId(), }; vm.source_mappings.init(&vm.saved_source_map_table); vm.regular_event_loop.tasks = EventLoop.Queue.init( @@ -2032,7 +2032,7 @@ pub const VirtualMachine = struct { .origin_timestamp = getOriginTimestamp(), .ref_strings = JSC.RefString.Map.init(allocator), .ref_strings_mutex = .{}, - .debug_thread_id = if (Environment.allow_assert) std.Thread.getCurrentId() else {}, + .debug_thread_id = if (Environment.allow_assert) std.Thread.getCurrentId(), }; vm.source_mappings.init(&vm.saved_source_map_table); vm.regular_event_loop.tasks = EventLoop.Queue.init( @@ -2188,7 +2188,7 @@ pub const VirtualMachine = struct { .ref_strings_mutex = .{}, .standalone_module_graph = worker.parent.standalone_module_graph, .worker = worker, - .debug_thread_id = if (Environment.allow_assert) std.Thread.getCurrentId() else {}, + .debug_thread_id = if (Environment.allow_assert) std.Thread.getCurrentId(), }; vm.source_mappings.init(&vm.saved_source_map_table); vm.regular_event_loop.tasks = EventLoop.Queue.init( @@ -2278,7 +2278,7 @@ pub const VirtualMachine = struct { .origin_timestamp = getOriginTimestamp(), .ref_strings = JSC.RefString.Map.init(allocator), .ref_strings_mutex = .{}, - .debug_thread_id = if (Environment.allow_assert) std.Thread.getCurrentId() else {}, + .debug_thread_id = if (Environment.allow_assert) std.Thread.getCurrentId(), }; vm.source_mappings.init(&vm.saved_source_map_table); vm.regular_event_loop.tasks = EventLoop.Queue.init( diff --git a/src/bun.js/node/node_fs.zig b/src/bun.js/node/node_fs.zig index 3a64db9dbe2bdf..470da8706ddfd1 100644 --- a/src/bun.js/node/node_fs.zig +++ b/src/bun.js/node/node_fs.zig @@ -5697,7 +5697,7 @@ pub const NodeFS = struct { defer bun.OSPathBufferPool.put(tmp); @memcpy(tmp[0..slice.len], slice); return bun.strings.fromWPath(&this.sync_error_buf, tmp[0..slice.len]); - } else {} + } } fn cpSyncInner( diff --git a/src/bun.js/webcore.zig b/src/bun.js/webcore.zig index 8699b4b8a7fdc1..cf53ac74c86012 100644 --- a/src/bun.js/webcore.zig +++ b/src/bun.js/webcore.zig @@ -267,8 +267,7 @@ pub const Prompt = struct { // unset `ENABLE_VIRTUAL_TERMINAL_INPUT` on windows. This prevents backspace from // deleting the entire line const original_mode: if (Environment.isWindows) ?bun.windows.DWORD else void = if (comptime Environment.isWindows) - bun.win32.unsetStdioModeFlags(0, bun.windows.ENABLE_VIRTUAL_TERMINAL_INPUT) catch null - else {}; + bun.win32.unsetStdioModeFlags(0, bun.windows.ENABLE_VIRTUAL_TERMINAL_INPUT) catch null; defer if (comptime Environment.isWindows) { if (original_mode) |mode| { diff --git a/src/cli/bunx_command.zig b/src/cli/bunx_command.zig index dcd75f5647bef9..3256f302edcbda 100644 --- a/src/cli/bunx_command.zig +++ b/src/cli/bunx_command.zig @@ -715,7 +715,7 @@ pub const BunxCommand = struct { .windows = if (Environment.isWindows) .{ .loop = bun.JSC.EventLoopHandle.init(bun.JSC.MiniEventLoop.initGlobal(this_transpiler.env)), - } else {}, + }, }) catch |err| { Output.prettyErrorln("error: bunx failed to install {s} due to error {s}", .{ install_param, @errorName(err) }); Global.exit(1); diff --git a/src/cli/create_command.zig b/src/cli/create_command.zig index 2723e33f5a718a..bc85f9533113b0 100644 --- a/src/cli/create_command.zig +++ b/src/cli/create_command.zig @@ -154,7 +154,7 @@ fn execTask(allocator: std.mem.Allocator, task_: string, cwd: string, _: string, .windows = if (Environment.isWindows) .{ .loop = bun.JSC.EventLoopHandle.init(bun.JSC.MiniEventLoop.initGlobal(null)), - } else {}, + }, }) catch return; } @@ -475,18 +475,14 @@ pub const CreateCommand = struct { }; var destination_buf: if (Environment.isWindows) bun.WPathBuffer else void = undefined; - const dst_without_trailing_slash: if (Environment.isWindows) string else void = if (comptime Environment.isWindows) - strings.withoutTrailingSlash(destination) - else {}; + const dst_without_trailing_slash: if (Environment.isWindows) string else void = if (comptime Environment.isWindows) strings.withoutTrailingSlash(destination); if (comptime Environment.isWindows) { strings.copyU8IntoU16(&destination_buf, dst_without_trailing_slash); destination_buf[dst_without_trailing_slash.len] = std.fs.path.sep; } var template_path_buf: if (Environment.isWindows) bun.WPathBuffer else void = undefined; - const src_without_trailing_slash: if (Environment.isWindows) string else void = if (comptime Environment.isWindows) - strings.withoutTrailingSlash(abs_template_path) - else {}; + const src_without_trailing_slash: if (Environment.isWindows) string else void = if (comptime Environment.isWindows) strings.withoutTrailingSlash(abs_template_path); if (comptime Environment.isWindows) { strings.copyU8IntoU16(&template_path_buf, src_without_trailing_slash); template_path_buf[src_without_trailing_slash.len] = std.fs.path.sep; @@ -597,10 +593,10 @@ pub const CreateCommand = struct { &walker_, node, &progress, - if (comptime Environment.isWindows) dst_without_trailing_slash.len + 1 else {}, - if (comptime Environment.isWindows) &destination_buf else {}, - if (comptime Environment.isWindows) src_without_trailing_slash.len + 1 else {}, - if (comptime Environment.isWindows) &template_path_buf else {}, + if (comptime Environment.isWindows) dst_without_trailing_slash.len + 1, + if (comptime Environment.isWindows) &destination_buf, + if (comptime Environment.isWindows) src_without_trailing_slash.len + 1, + if (comptime Environment.isWindows) &template_path_buf, ); package_json_file = destination_dir.openFile("package.json", .{ .mode = .read_write }) catch null; @@ -1517,7 +1513,7 @@ pub const CreateCommand = struct { .windows = if (Environment.isWindows) .{ .loop = bun.JSC.EventLoopHandle.init(bun.JSC.MiniEventLoop.initGlobal(null)), - } else {}, + }, }); _ = try process.unwrap(); } diff --git a/src/cli/filter_run.zig b/src/cli/filter_run.zig index 9093ee3fa234c4..ba1a00ed90b545 100644 --- a/src/cli/filter_run.zig +++ b/src/cli/filter_run.zig @@ -557,7 +557,7 @@ pub fn runScriptsWithFilter(ctx: Command.Context) !noreturn { .stdout = if (Environment.isPosix) .buffer else .{ .buffer = try bun.default_allocator.create(bun.windows.libuv.Pipe) }, .stderr = if (Environment.isPosix) .buffer else .{ .buffer = try bun.default_allocator.create(bun.windows.libuv.Pipe) }, .cwd = std.fs.path.dirname(script.package_json_path) orelse "", - .windows = if (Environment.isWindows) .{ .loop = bun.JSC.EventLoopHandle.init(event_loop) } else {}, + .windows = if (Environment.isWindows) .{ .loop = bun.JSC.EventLoopHandle.init(event_loop) }, .stream = true, }, }; diff --git a/src/cli/init_command.zig b/src/cli/init_command.zig index 01d4d3112acd2e..5cbb0ad95c4b62 100644 --- a/src/cli/init_command.zig +++ b/src/cli/init_command.zig @@ -40,8 +40,7 @@ pub const InitCommand = struct { // unset `ENABLE_VIRTUAL_TERMINAL_INPUT` on windows. This prevents backspace from // deleting the entire line const original_mode: if (Environment.isWindows) ?bun.windows.DWORD else void = if (comptime Environment.isWindows) - bun.win32.unsetStdioModeFlags(0, bun.windows.ENABLE_VIRTUAL_TERMINAL_INPUT) catch null - else {}; + bun.win32.unsetStdioModeFlags(0, bun.windows.ENABLE_VIRTUAL_TERMINAL_INPUT) catch null; defer if (comptime Environment.isWindows) { if (original_mode) |mode| { diff --git a/src/cli/publish_command.zig b/src/cli/publish_command.zig index b62ae823d1ee0c..d1e26d06fcb176 100644 --- a/src/cli/publish_command.zig +++ b/src/cli/publish_command.zig @@ -53,8 +53,8 @@ pub const PublishCommand = struct { normalized_pkg_info: string, - publish_script: if (directory_publish) ?[]const u8 else void = if (directory_publish) null else {}, - postpublish_script: if (directory_publish) ?[]const u8 else void = if (directory_publish) null else {}, + publish_script: if (directory_publish) ?[]const u8 else void = if (directory_publish) null, + postpublish_script: if (directory_publish) ?[]const u8 else void = if (directory_publish) null, script_env: if (directory_publish) *DotEnv.Loader else void, const FromTarballError = OOM || error{ @@ -683,8 +683,7 @@ pub const PublishCommand = struct { // unset `ENABLE_VIRTUAL_TERMINAL_INPUT` on windows. This prevents backspace from // deleting the entire line const original_mode: if (Environment.isWindows) ?bun.windows.DWORD else void = if (comptime Environment.isWindows) - bun.win32.unsetStdioModeFlags(0, bun.windows.ENABLE_VIRTUAL_TERMINAL_INPUT) catch null - else {}; + bun.win32.unsetStdioModeFlags(0, bun.windows.ENABLE_VIRTUAL_TERMINAL_INPUT) catch null; defer if (comptime Environment.isWindows) { if (original_mode) |mode| { diff --git a/src/cli/run_command.zig b/src/cli/run_command.zig index 4ae3c93ed1c564..78fbbf3c7e52cc 100644 --- a/src/cli/run_command.zig +++ b/src/cli/run_command.zig @@ -349,7 +349,7 @@ pub const RunCommand = struct { .windows = if (Environment.isWindows) .{ .loop = JSC.EventLoopHandle.init(JSC.MiniEventLoop.initGlobal(env)), - } else {}, + }, }) catch |err| { if (!silent) { Output.prettyErrorln("error: Failed to run script {s} due to error {s}", .{ name, @errorName(err) }); @@ -513,7 +513,7 @@ pub const RunCommand = struct { .windows = if (Environment.isWindows) .{ .loop = JSC.EventLoopHandle.init(JSC.MiniEventLoop.initGlobal(env)), - } else {}, + }, }) catch |err| { bun.handleErrorReturnTrace(err, @errorReturnTrace()); diff --git a/src/cli/upgrade_command.zig b/src/cli/upgrade_command.zig index f39e4b906ed790..61f5b0ebdf09d1 100644 --- a/src/cli/upgrade_command.zig +++ b/src/cli/upgrade_command.zig @@ -686,7 +686,7 @@ pub const UpgradeCommand = struct { .windows = if (Environment.isWindows) .{ .loop = bun.JSC.EventLoopHandle.init(bun.JSC.MiniEventLoop.initGlobal(null)), - } else {}, + }, }) catch |err| { Output.prettyErrorln("error: Failed to spawn Expand-Archive on {s} due to error {s}", .{ tmpname, @errorName(err) }); Global.exit(1); diff --git a/src/css/css_parser.zig b/src/css/css_parser.zig index 306b4d4dcd41cc..83c1b0750f570d 100644 --- a/src/css/css_parser.zig +++ b/src/css/css_parser.zig @@ -362,7 +362,7 @@ pub fn DefineShorthand(comptime T: type, comptime property_name: PropertyIdTag) // const property_id = @unionInit( // PropertyId, // field.name, - // if (@hasDecl(T.VendorPrefixMap, field.name)) vendor_prefix else {}, + // if (@hasDecl(T.VendorPrefixMap, field.name)) vendor_prefix, // ); // const value = property.longhand(&property_id); // if (@as(PropertyIdTag, value) == @as(PropertyIdTag, property_id)) { @@ -403,7 +403,7 @@ pub fn DefineShorthand(comptime T: type, comptime property_name: PropertyIdTag) // out[i] = @unionInit( // PropertyId, // field.name, - // if (@hasField(T.VendorPrefixMap, field.name)) vendor_prefix else {}, + // if (@hasField(T.VendorPrefixMap, field.name)) vendor_prefix, // ); // } diff --git a/src/hive_array.zig b/src/hive_array.zig index fd9085b03551ca..375e7929c811a4 100644 --- a/src/hive_array.zig +++ b/src/hive_array.zig @@ -75,7 +75,7 @@ pub fn HiveArray(comptime T: type, comptime capacity: u16) type { pub fn init(allocator: std.mem.Allocator) This { return .{ .allocator = allocator, - .hive = if (capacity > 0) HiveArray(T, capacity).init() else {}, + .hive = if (capacity > 0) HiveArray(T, capacity).init(), }; } diff --git a/src/install/install.zig b/src/install/install.zig index 93ff07b8d0147d..f01403d65b9c40 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -1494,10 +1494,10 @@ pub fn NewPackageInstall(comptime kind: PkgInstallKind) type { cached_package_dir: std.fs.Dir = undefined, walker: Walker = undefined, subdir: std.fs.Dir = if (Environment.isWindows) std.fs.Dir{ .fd = std.os.windows.INVALID_HANDLE_VALUE } else undefined, - buf: bun.windows.WPathBuffer = if (Environment.isWindows) undefined else {}, - buf2: bun.windows.WPathBuffer = if (Environment.isWindows) undefined else {}, - to_copy_buf: if (Environment.isWindows) []u16 else void = if (Environment.isWindows) undefined else {}, - to_copy_buf2: if (Environment.isWindows) []u16 else void = if (Environment.isWindows) undefined else {}, + buf: bun.windows.WPathBuffer = if (Environment.isWindows) undefined, + buf2: bun.windows.WPathBuffer = if (Environment.isWindows) undefined, + to_copy_buf: if (Environment.isWindows) []u16 else void = if (Environment.isWindows) undefined, + to_copy_buf2: if (Environment.isWindows) []u16 else void = if (Environment.isWindows) undefined, pub fn deinit(this: *@This()) void { if (!Environment.isWindows) { @@ -1888,7 +1888,7 @@ pub fn NewPackageInstall(comptime kind: PkgInstallKind) type { head2: if (Environment.isWindows) []u16 else void, ) !u32 { var real_file_count: u32 = 0; - var queue = if (Environment.isWindows) HardLinkWindowsInstallTask.getQueue() else {}; + var queue = if (Environment.isWindows) HardLinkWindowsInstallTask.getQueue(); while (try walker.next()) |entry| { if (comptime Environment.isPosix) { @@ -14998,7 +14998,7 @@ pub const PackageManager = struct { // added/removed/updated direct dependencies. Output.pretty( \\ - \\Saved {s} ({d} package{s}) + \\Saved {s} ({d} package{s}) , .{ switch (save_format) { .text => "bun.lock", diff --git a/src/install/lifecycle_script_runner.zig b/src/install/lifecycle_script_runner.zig index 6b054644a0f0c6..42c71494eae16f 100644 --- a/src/install/lifecycle_script_runner.zig +++ b/src/install/lifecycle_script_runner.zig @@ -206,11 +206,9 @@ pub const LifecycleScriptSubprocess = struct { }, .cwd = cwd, - .windows = if (Environment.isWindows) - .{ - .loop = JSC.EventLoopHandle.init(&manager.event_loop), - } - else {}, + .windows = if (Environment.isWindows) .{ + .loop = JSC.EventLoopHandle.init(&manager.event_loop), + }, .stream = false, }; diff --git a/src/install/lockfile.zig b/src/install/lockfile.zig index c8d16268ccec18..25f96d6a2ac5a0 100644 --- a/src/install/lockfile.zig +++ b/src/install/lockfile.zig @@ -689,7 +689,7 @@ pub const Tree = struct { lockfile: *const Lockfile, manager: if (method == .filter) *const PackageManager else void, sort_buf: std.ArrayListUnmanaged(DependencyID) = .{}, - workspace_filters: if (method == .filter) []const WorkspaceFilter else void = if (method == .filter) &.{} else {}, + workspace_filters: if (method == .filter) []const WorkspaceFilter else void = if (method == .filter) &.{}, install_root_dependencies: if (method == .filter) bool else void, path_buf: []u8, @@ -1300,7 +1300,7 @@ pub fn cleanWithLogger( exact_versions: bool, comptime log_level: PackageManager.Options.LogLevel, ) !*Lockfile { - var timer: if (log_level.isVerbose()) std.time.Timer else void = if (comptime log_level.isVerbose()) try std.time.Timer.start() else {}; + var timer: if (log_level.isVerbose()) std.time.Timer else void = if (comptime log_level.isVerbose()) try std.time.Timer.start(); const old_trusted_dependencies = old.trusted_dependencies; const old_scripts = old.scripts; @@ -1616,7 +1616,7 @@ pub fn hoist( Tree.invalid_id, method, &builder, - if (method == .filter) manager.options.log_level else {}, + if (method == .filter) manager.options.log_level, ); // This goes breadth-first @@ -1626,7 +1626,7 @@ pub fn hoist( item.hoist_root_id, method, &builder, - if (method == .filter) manager.options.log_level else {}, + if (method == .filter) manager.options.log_level, ); } diff --git a/src/install/npm.zig b/src/install/npm.zig index e0801946d1a9e3..d344de30e5ca5d 100644 --- a/src/install/npm.zig +++ b/src/install/npm.zig @@ -1115,7 +1115,7 @@ pub const PackageManifest = struct { else tmp_path; - var is_using_o_tmpfile = if (Environment.isLinux) false else {}; + var is_using_o_tmpfile = if (Environment.isLinux) false; const file = brk: { const flags = bun.O.WRONLY; const mask = if (Environment.isPosix) 0o664 else 0; diff --git a/src/js_lexer.zig b/src/js_lexer.zig index 1560f026213327..251cd7c08a5807 100644 --- a/src/js_lexer.zig +++ b/src/js_lexer.zig @@ -117,7 +117,7 @@ fn NewLexer_( const is_json = json_options.is_json; const json = json_options; const JSONBool = if (is_json) bool else void; - const JSONBoolDefault: JSONBool = if (is_json) true else {}; + const JSONBoolDefault: JSONBool = if (is_json) true; pub const Error = error{ UTF8Fail, @@ -180,8 +180,7 @@ fn NewLexer_( } else void = if (json_options.guess_indentation) - .{} - else {}, + .{}, pub inline fn loc(self: *const LexerType) logger.Loc { return logger.usize2Loc(self.start); diff --git a/src/js_parser.zig b/src/js_parser.zig index 62e6515a8eb5d0..6de13bc2b2b4ab 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -8856,12 +8856,12 @@ fn NewParser_( try p.lexer.next(); // The type following "extends" is not permitted to be another conditional type - var extends_type = if (get_metadata) TypeScript.Metadata.default else {}; + var extends_type = if (get_metadata) TypeScript.Metadata.default; try p.skipTypeScriptTypeWithOpts( .lowest, TypeScript.SkipTypeOptions.Bitset.initOne(.disallow_conditional_types), get_metadata, - if (get_metadata) &extends_type else {}, + if (get_metadata) &extends_type, ); if (comptime get_metadata) { @@ -11259,8 +11259,7 @@ fn NewParser_( var is_single_line = !p.lexer.has_newline_before; // this variable should not exist if we're not in a typescript file var had_type_only_imports = if (comptime is_typescript_enabled) - false - else {}; + false; while (p.lexer.token != .t_close_brace) { // The alias may be a keyword; @@ -22103,7 +22102,7 @@ fn NewParser_( @compileError("only_scan_imports_and_do_not_visit must not run this."); } - const initial_scope = if (comptime Environment.allow_assert) p.current_scope else {}; + const initial_scope = if (comptime Environment.allow_assert) p.current_scope; { // Save the current control-flow liveness. This represents if we are diff --git a/src/json_parser.zig b/src/json_parser.zig index 47267b62ee56d3..c7a95ead6e7a36 100644 --- a/src/json_parser.zig +++ b/src/json_parser.zig @@ -250,13 +250,9 @@ fn JSONLikeParser_( const DuplicateNodeType = comptime if (opts.json_warn_duplicate_keys) *HashMapPool.LinkedList.Node else void; const HashMapType = comptime if (opts.json_warn_duplicate_keys) HashMapPool.HashMap else void; - var duplicates_node: DuplicateNodeType = if (comptime opts.json_warn_duplicate_keys) - HashMapPool.get(p.allocator) - else {}; + var duplicates_node: DuplicateNodeType = if (comptime opts.json_warn_duplicate_keys) HashMapPool.get(p.allocator); - var duplicates: HashMapType = if (comptime opts.json_warn_duplicate_keys) - duplicates_node.data - else {}; + var duplicates: HashMapType = if (comptime opts.json_warn_duplicate_keys) duplicates_node.data; defer { if (comptime opts.json_warn_duplicate_keys) { diff --git a/src/open.zig b/src/open.zig index c14c2895c96288..e95489208073d6 100644 --- a/src/open.zig +++ b/src/open.zig @@ -39,7 +39,7 @@ pub fn openURL(url: stringZ) void { .windows = if (Environment.isWindows) .{ .loop = bun.JSC.EventLoopHandle.init(bun.JSC.MiniEventLoop.initGlobal(null)), - } else {}, + }, }) catch break :maybe_fallback) { // don't fallback: .result => |*result| if (result.isOK()) return, diff --git a/src/patch.zig b/src/patch.zig index eaddbc26c9a114..771643d8cefd3a 100644 --- a/src/patch.zig +++ b/src/patch.zig @@ -1285,7 +1285,7 @@ pub fn spawnOpts( .windows = if (bun.Environment.isWindows) .{ .loop = switch (loop.*) { .js => |x| .{ .js = x }, .mini => |*x| .{ .mini = x }, - } } else {}, + } }, }; } diff --git a/src/shell/subproc.zig b/src/shell/subproc.zig index c88aa8190a97f7..940e117562ebe4 100644 --- a/src/shell/subproc.zig +++ b/src/shell/subproc.zig @@ -830,7 +830,7 @@ pub const ShellSubprocess = struct { .windows = if (Environment.isWindows) bun.spawn.WindowsSpawnOptions.WindowsOptions{ .hide_window = true, .loop = event_loop, - } else {}, + }, }; spawn_args.argv.append(allocator, null) catch { diff --git a/src/string.zig b/src/string.zig index 843340c410f8a5..183f796c8fba22 100644 --- a/src/string.zig +++ b/src/string.zig @@ -1375,7 +1375,7 @@ pub const SliceWithUnderlyingString = struct { utf8: ZigString.Slice = ZigString.Slice.empty, underlying: String = String.dead, - did_report_extra_memory_debug: bun.DebugOnly(bool) = if (bun.Environment.allow_assert) false else {}, + did_report_extra_memory_debug: bun.DebugOnly(bool) = if (bun.Environment.allow_assert) false, pub inline fn reportExtraMemory(this: *SliceWithUnderlyingString, vm: *JSC.VM) void { if (comptime bun.Environment.allow_assert) { diff --git a/src/sys.zig b/src/sys.zig index c1c1da2beb42a2..73272f5eb9ee8d 100644 --- a/src/sys.zig +++ b/src/sys.zig @@ -893,7 +893,7 @@ pub fn normalizePathWindows( if (comptime T != u8 and T != u16) { @compileError("normalizePathWindows only supports u8 and u16 character types"); } - const wbuf = if (T != u16) bun.WPathBufferPool.get() else {}; + const wbuf = if (T != u16) bun.WPathBufferPool.get(); defer if (T != u16) bun.WPathBufferPool.put(wbuf); var path = if (T == u16) path_ else bun.strings.convertUTF8toUTF16InBuffer(wbuf, path_);