diff options
Diffstat (limited to 'src/Server.zig')
| -rw-r--r-- | src/Server.zig | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/src/Server.zig b/src/Server.zig index 65129a5..eff61d1 100644 --- a/src/Server.zig +++ b/src/Server.zig @@ -347,8 +347,8 @@ fn publishMessage( // in the chunks buf. // The reason for this strategy is to avoid any intermediary allocations between // the publishers read buffer, and the subscribers write buffer. - var chunk_count: usize = 7; - var msg_chunks_buf: [10][]const u8 = undefined; + var chunk_count: usize = 6; + var msg_chunks_buf: [9][]const u8 = undefined; var msg_chunks: ArrayList([]const u8) = .initBuffer(&msg_chunks_buf); switch (pub_or_hpub) { @@ -364,20 +364,10 @@ fn publishMessage( msg_chunks.appendBounded(reply_to) catch unreachable; msg_chunks.appendBounded(" ") catch unreachable; } - switch (pub_or_hpub) { - .hpub => { - chunk_count += 1; - var hlen_buf: [std.fmt.count("{d} ", .{std.math.maxInt(usize)})]u8 = undefined; - msg_chunks.appendBounded( - std.fmt.bufPrint(&hlen_buf, "{d} ", .{hpubmsg.header_bytes}) catch unreachable, - ) catch unreachable; - }, - else => {}, + if (pub_or_hpub == .hpub) { + chunk_count += 1; + msg_chunks.appendBounded(hpubmsg.header_bytes) catch unreachable; } - var len_buf: [std.fmt.count("{d}\r\n", .{std.math.maxInt(usize)})]u8 = undefined; - msg_chunks.appendBounded( - std.fmt.bufPrint(&len_buf, "{d}\r\n", .{msg.payload.len - 2}) catch unreachable, - ) catch unreachable; msg_chunks.appendBounded(msg.payload) catch unreachable; try subscription.send(io, msg_chunks.items[0..chunk_count]); |
