mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-01-12 17:08:39 -09:00
Revise @branchHint probabilities
Arguably, my previous use of @setCold() was incorrect in some cases, but it happened to work out better than not providing any hints. Let's use the more granular hints now that Zig 0.14 supports them.
This commit is contained in:
parent
5438312440
commit
af7163acf6
3 changed files with 4 additions and 4 deletions
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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", .{});
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue