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");
},
.msg => |m| {
@branchHint(.likely);
try self.to_client.print(
"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| {
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", .{
hmsg.msg.subject,
hmsg.msg.sid,

View File

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