Add branch hints for high performance messaging.

This commit is contained in:
2026-01-02 20:32:56 +00:00
parent 9e9f7e8e50
commit 90b5b1548f
2 changed files with 4 additions and 1 deletions

View File

@@ -65,6 +65,7 @@ pub fn start(self: *Client, io: std.Io, alloc: std.mem.Allocator, queue: *std.Io
_ = try self.to_client.write("\r\n"); _ = try self.to_client.write("\r\n");
}, },
.msg => |m| { .msg => |m| {
@branchHint(.likely);
try self.to_client.print( try self.to_client.print(
"MSG {s} {s} {s} {d}\r\n{s}\r\n", "MSG {s} {s} {s} {d}\r\n{s}\r\n",
.{ .{
@@ -77,7 +78,7 @@ pub fn start(self: *Client, io: std.Io, alloc: std.mem.Allocator, queue: *std.Io
); );
}, },
.hmsg => |hmsg| { .hmsg => |hmsg| {
std.log.debug("Sending hmsg: {any}", .{hmsg}); @branchHint(.likely);
try self.to_client.print("HMSG {s} {s} {s} {d} {d}\r\n{s}\r\n", .{ try self.to_client.print("HMSG {s} {s} {s} {d} {d}\r\n{s}\r\n", .{
hmsg.msg.subject, hmsg.msg.subject,
hmsg.msg.sid, hmsg.msg.sid,

View File

@@ -297,9 +297,11 @@ pub const Message = union(MessageType) {
return .{ .connect = try res.dupe(alloc) }; return .{ .connect = try res.dupe(alloc) };
}, },
.@"pub" => { .@"pub" => {
@branchHint(.likely);
return parsePub(alloc, in); return parsePub(alloc, in);
}, },
.hpub => { .hpub => {
@branchHint(.likely);
return parseHPub(alloc, in); return parseHPub(alloc, in);
}, },
.ping => { .ping => {