diff options
Diffstat (limited to 'src/Names.zig')
| -rw-r--r-- | src/Names.zig | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/Names.zig b/src/Names.zig index 0c8ba075..63eec14f 100644 --- a/src/Names.zig +++ b/src/Names.zig @@ -33,6 +33,10 @@ query_len: u8 = 0, /// Bumped whenever `hits` change: the rows are made again only then. gen: u32 = 0, +/// The query is `query_buf[0..query_len]`: what lies past it is undefined +/// (0xAA in Debug, not in a release build), so no digest reads it. +pub const replica = .{ .len = .{.{ "query_buf", "query_len" }} }; + pub const Cand = struct { /// The row: `bytes[start..][0..len]`. start: u32, @@ -146,8 +150,7 @@ pub fn typed(n: *Names, gpa: std.mem.Allocator, text: []const u8) void { pub fn rescore(n: *Names, gpa: std.mem.Allocator) void { const q = n.queryText(); const empty = std.mem.trim(u8, q, " ").len == 0; - const io = std.Io.Threaded.global_single_threaded.io(); - const started = std.Io.Clock.awake.now(io); + const started = pardes.FrameStats.nowNs(); const had = n.hits.items.len; const was_scored = n.scored; var count: usize = 0; @@ -164,8 +167,7 @@ pub fn rescore(n: *Names, gpa: std.mem.Allocator) void { const s = if (empty) 0 else match(q, key, n.lower.items[c.start + c.key ..][0..c.key_len], c.base, null, null, null); if (s) |score| n.hits.append(gpa, .{ .cand = i, .score = score }) catch break; // The clock every 256 candidates: reading it is not free either. - if (!empty and count % 256 == 255 and - started.durationTo(std.Io.Clock.awake.now(io)).toNanoseconds() > score_budget_ns) break; + if (!empty and count % 256 == 255 and pardes.tape.over(started, score_budget_ns)) break; } // An empty query keeps the source's order (the walk's, recency): no // row moves as the walk goes on, it only grows at the foot. |
