diff --git a/src/bin_export.zig b/src/bin_export.zig index 4c445cf..ea21d9d 100644 --- a/src/bin_export.zig +++ b/src/bin_export.zig @@ -118,7 +118,7 @@ pub const Thread = struct { } fn flush(t: *Thread, expected_len: usize) void { - @branchHint(.cold); + @branchHint(.unlikely); const block = createBlock(t); defer block.deinit(); diff --git a/src/json_export.zig b/src/json_export.zig index 95ccf85..3937b3f 100644 --- a/src/json_export.zig +++ b/src/json_export.zig @@ -73,7 +73,7 @@ pub const Writer = struct { dir_entry_open: bool = false, fn flush(ctx: *Writer, bytes: usize) void { - @branchHint(.cold); + @branchHint(.unlikely); // This can only really happen when the root path exceeds PATH_MAX, // in which case we would probably have error'ed out earlier anyway. if (bytes > ctx.buf.len) ui.die("Error writing JSON export: path too long.\n", .{}); diff --git a/src/json_import.zig b/src/json_import.zig index 0b69f22..28224e6 100644 --- a/src/json_import.zig +++ b/src/json_import.zig @@ -83,7 +83,6 @@ const Parser = struct { } fn fill(p: *Parser) void { - @branchHint(.cold); p.rdoff = 0; p.rdsize = (if (p.zstd) |z| z.read(p.rd, &p.buf) else p.rd.read(&p.buf)) catch |e| switch (e) { error.IsDir => p.die("not a file"), // should be detected at open() time, but no flag for that... @@ -98,6 +97,7 @@ const Parser = struct { // (Returning a '?u8' here is nicer but kills performance by about +30%) fn nextByte(p: *Parser) u8 { if (p.rdoff == p.rdsize) { + @branchHint(.unlikely); p.fill(); if (p.rdsize == 0) return 0; } @@ -133,7 +133,7 @@ const Parser = struct { } fn stringContentSlow(p: *Parser, buf: []u8, head: u8, off: usize) []u8 { - @branchHint(.cold); + @branchHint(.unlikely); var b = head; var n = off; while (true) {