Remove redundant comptime

Move edge together at the end of the switch
This commit is contained in:
2025-04-03 16:07:57 -04:00
parent ef36894c70
commit d60d1fd335

View File

@@ -64,8 +64,8 @@ const SaprusMessage = union(SaprusPacketType) {
switch (self) { switch (self) {
.relay => |r| try toBytesAux(Relay.Header, r.header, r.payload, w, allocator), .relay => |r| try toBytesAux(Relay.Header, r.header, r.payload, w, allocator),
.file_transfer => return SaprusError.NotImplementedSaprusType,
.connection => |c| try toBytesAux(Connection.Header, c.header, c.payload, w, allocator), .connection => |c| try toBytesAux(Connection.Header, c.header, c.payload, w, allocator),
.file_transfer => return SaprusError.NotImplementedSaprusType,
} }
return buf.toOwnedSlice(); return buf.toOwnedSlice();
@@ -77,15 +77,15 @@ const SaprusMessage = union(SaprusPacketType) {
switch (@as(SaprusPacketType, @enumFromInt(try r.readInt(u16, .big)))) { switch (@as(SaprusPacketType, @enumFromInt(try r.readInt(u16, .big)))) {
.relay => return fromBytesAux(.relay, Relay.Header, r, allocator), .relay => return fromBytesAux(.relay, Relay.Header, r, allocator),
.file_transfer => return SaprusError.NotImplementedSaprusType,
.connection => return fromBytesAux(.connection, Connection.Header, r, allocator), .connection => return fromBytesAux(.connection, Connection.Header, r, allocator),
.file_transfer => return SaprusError.NotImplementedSaprusType,
else => return SaprusError.UnknownSaprusType, else => return SaprusError.UnknownSaprusType,
} }
} }
}; };
inline fn toBytesAux( inline fn toBytesAux(
comptime Header: type, Header: type,
header: Header, header: Header,
payload: []const u8, payload: []const u8,
w: std.ArrayList(u8).Writer, w: std.ArrayList(u8).Writer,
@@ -100,8 +100,8 @@ inline fn toBytesAux(
} }
inline fn fromBytesAux( inline fn fromBytesAux(
comptime packet: SaprusPacketType, packet: SaprusPacketType,
comptime Header: type, Header: type,
r: StringReader, r: StringReader,
allocator: Allocator, allocator: Allocator,
) !SaprusMessage { ) !SaprusMessage {