From 3b490fc3c8864eec0c3f4e92a2a2014711ff09c8 Mon Sep 17 00:00:00 2001 From: Robby Zambito Date: Tue, 6 Jan 2026 22:26:49 -0500 Subject: Cleanup Server.zig --- src/Server.zig | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Server.zig b/src/Server.zig index c2cc17d..7e30b76 100644 --- a/src/Server.zig +++ b/src/Server.zig @@ -24,7 +24,7 @@ const Server = @This(); const builtin = @import("builtin"); -pub const Subscription = struct { +const Subscription = struct { subject: []const u8, client_id: usize, sid: []const u8, @@ -384,9 +384,10 @@ fn unsubscribe( } } -const parseUnsigned = std.fmt.parseUnsigned; - -fn getBufferSizes(io: Io) struct { usize, usize } { +/// Probes the system for an appropriate buffer size. +/// Try to match the kernel socket buffers to maximize +/// the amount of data we push through each syscall. +fn getBufferSizes(io: Io) @Tuple(&.{ usize, usize }) { const default_size = 4 * 1024; const default = .{ default_size, default_size }; @@ -409,7 +410,7 @@ fn readBufferSize(io: Io, dir: anytype, filename: []const u8, buf: []u8, default return default; }; - return parseUnsigned(usize, bytes[0 .. bytes.len - 1], 10) catch |err| { + return std.fmt.parseUnsigned(usize, bytes[0 .. bytes.len - 1], 10) catch |err| { log.err("couldn't parse {s}: {any}", .{ bytes[0 .. bytes.len - 1], err }); return default; }; -- cgit