Skip to content

Commit 426f2b4

Browse files
committed
remove inlines
Let the compiler decide what to inline.
1 parent cc547bb commit 426f2b4

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/frame.zig

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ pub const Frame = struct {
4545
};
4646

4747
pub const max_header = 14; // 1 + 9 + 4 (flags|opcode + mask|payload_len + masking_key)
48-
pub const empty_payload = &[_]u8{};
4948

5049
fin: u1,
5150
rsv1: u1 = 0,

src/stream.zig

+6-7
Original file line numberDiff line numberDiff line change
@@ -268,31 +268,30 @@ pub fn Reader(comptime ReaderType: type) type {
268268
};
269269
}
270270

271-
// TODO does all this inlines make sense
272-
inline fn readBit(self: *Self) !u1 {
271+
fn readBit(self: *Self) !u1 {
273272
return try self.bit_reader.readBitsNoEof(u1, 1);
274273
}
275-
inline fn readOpcode(self: *Self) !Frame.Opcode {
274+
fn readOpcode(self: *Self) !Frame.Opcode {
276275
return try Frame.Opcode.decode(try self.bit_reader.readBitsNoEof(u4, 4));
277276
}
278-
inline fn readPayloadLen(self: *Self) !u64 {
277+
fn readPayloadLen(self: *Self) !u64 {
279278
const payload_len = try self.bit_reader.readBitsNoEof(u64, 7);
280279
return switch (payload_len) {
281280
126 => try self.bit_reader.readBitsNoEof(u64, 8 * 2),
282281
127 => try self.bit_reader.readBitsNoEof(u64, 8 * 8),
283282
else => payload_len,
284283
};
285284
}
286-
inline fn readAll(self: *Self, buffer: []u8) !void {
285+
fn readAll(self: *Self, buffer: []u8) !void {
287286
var index: usize = 0;
288287
while (index != buffer.len) {
289288
const amt = try self.bit_reader.reader.read(buffer[index..]);
290289
if (amt == 0) return error.EndOfStream;
291290
index += amt;
292291
}
293292
}
294-
inline fn readPayload(self: *Self, payload_len: u64, masked: bool) ![]u8 {
295-
if (payload_len == 0) return Frame.empty_payload;
293+
fn readPayload(self: *Self, payload_len: u64, masked: bool) ![]u8 {
294+
if (payload_len == 0) return &.{};
296295
var masking_key = [_]u8{0} ** 4;
297296
if (masked) try self.readAll(&masking_key);
298297
const payload = try self.allocator.alloc(u8, payload_len);

0 commit comments

Comments
 (0)