From 05c99f39161b6f3bff3795aabf182f0f041b5124 Mon Sep 17 00:00:00 2001 From: Altagos Date: Mon, 16 Feb 2026 13:58:58 +0100 Subject: [PATCH] update to latest zig master --- build.zig.zon | 6 +++--- src/st/http.zig | 34 ++++++++++++++++------------------ 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index aa90b01..5f23271 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -11,11 +11,11 @@ .hash = "pretty-0.1.0--Y3D26JKAAABPfRqFy6oUakwiYAawqqbU6xF0_5ziP-l", }, .zqlite = .{ - .url = "git+https://github.com/karlseguin/zqlite.zig?ref=master#b44ed5cdc64859b08446c246f307e65ebe2b2d9c", - .hash = "zqlite-0.0.0-RWLaY_y_mADh2LdbDrG_2HT2dBAcsAR8Jig_7-dOJd0B", + .url = "git+https://github.com/altagos/zqlite.zig?ref=master#f95c6bc7b182a8c18d8341fba031fa6d5d2ffbd1", + .hash = "zqlite-0.0.1-RWLaY-ybmAD3n26uDYVbLm772-sPi5WsVfxTQmGuZC9B", }, .sqlite3 = .{ - .url = "https://www.sqlite.org/2026/sqlite-amalgamation-3510200.zip", + .url = "http://www.sqlite.org/2026/sqlite-amalgamation-3510200.zip", .hash = "N-V-__8AALNmqgBz73I7J8GlQS_kCPTRgxS0rm8gXcEM8Evk", }, }, diff --git a/src/st/http.zig b/src/st/http.zig index 6f5df13..07daf55 100644 --- a/src/st/http.zig +++ b/src/st/http.zig @@ -73,7 +73,7 @@ pub const Limiter = struct { defer l.mutex.unlock(io); if (l.time) |t| { - const dur = t.durationTo(Io.Clock.now(.real, io) catch return false); + const dur = t.durationTo(Io.Clock.now(.real, io)); if (dur.toSeconds() > 0) { l.semaphor.set(io, l.points); l.time = null; @@ -89,7 +89,7 @@ pub const Limiter = struct { defer l.mutex.unlock(io); if (l.time == null) { - const now = try Io.Clock.now(.real, io); + const now = Io.Clock.now(.real, io); l.time = now.addDuration(.fromMilliseconds(l.duration)); } @@ -98,7 +98,7 @@ pub const Limiter = struct { pub fn timeToReset(l: *Limiter, io: Io) Io.Duration { if (l.time) |t| { - return t.durationTo(Io.Clock.now(.real, io) catch return .zero); + return t.durationTo(Io.Clock.now(.real, io)); } return .zero; } @@ -329,7 +329,7 @@ pub const Client = struct { log.debug("requesting: {s}", .{uri.path.percent_encoded}); - const start: ?Io.Timestamp = Io.Clock.now(.real, client.io) catch null; + const start = Io.Clock.now(.real, client.io); switch (opts.body) { .empty => try req.sendBodiless(), @@ -352,23 +352,21 @@ pub const Client = struct { _ = client.total_requests.fetchAdd(1, .seq_cst); - if (start) |s| blk: { - const latency: u64 = @intCast(s.durationTo(Io.Clock.now(.real, client.io) catch break :blk).toMilliseconds()); - const old_average = client.average_latency.load(.seq_cst); - var new_average: u64 = 0; + const latency: u64 = @intCast(start.durationTo(Io.Clock.now(.real, client.io)).toMilliseconds()); + const old_average = client.average_latency.load(.seq_cst); + var new_average: u64 = 0; - if (old_average == 0) { - new_average = latency; - } else { - const total_reqs = client.total_requests.load(.seq_cst); - new_average = old_average * (total_reqs - 1) / total_reqs + latency / total_reqs; - } + if (old_average == 0) { + new_average = latency; + } else { + const total_reqs = client.total_requests.load(.seq_cst); + new_average = old_average * (total_reqs - 1) / total_reqs + latency / total_reqs; + } - client.average_latency.store(new_average, .seq_cst); - _ = client.total_latency.fetchAdd(latency, .seq_cst); + client.average_latency.store(new_average, .seq_cst); + _ = client.total_latency.fetchAdd(latency, .seq_cst); - log.debug("latency: {} ms - average: {}ms", .{ latency, new_average }); - } + log.debug("latency: {} ms - average: {}ms", .{ latency, new_average }); log.debug( "\x1b[2m[path = {s}]\x1b[0m received {s}{d} {s}\x1b[0m", -- 2.51.2