Skip to content

Commit a932207

Browse files
committed
refactor(msgpack): simplify endian constant definitions
- Remove version-specific endian handling switch statements - Use unified Endian.big and Endian.little constants - Remove obsolete TODO comment about timestamp - Clean up trailing whitespace
1 parent b222a2b commit a932207

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/msgpack.zig

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,8 @@ const Allocator = std.mem.Allocator;
99
const comptimePrint = std.fmt.comptimePrint;
1010
const native_endian = builtin.cpu.arch.endian();
1111

12-
const big_endian = switch (current_zig.minor) {
13-
11 => std.builtin.Endian.Big,
14-
12, 13, 14, 15, 16 => std.builtin.Endian.big,
15-
else => @compileError("not support current version zig"),
16-
};
17-
const little_endian = switch (current_zig.minor) {
18-
11 => std.builtin.Endian.Little,
19-
12, 13, 14, 15, 16 => std.builtin.Endian.little,
20-
else => @compileError("not support current version zig"),
21-
};
12+
const big_endian = std.builtin.Endian.big;
13+
const little_endian = std.builtin.Endian.little;
2214

2315
// Constants for improved code readability
2416
const MAX_POSITIVE_FIXINT: u8 = 0x7f;
@@ -166,7 +158,7 @@ pub const Payload = union(enum) {
166158
if (self.* != .map) {
167159
return Errors.NotMap;
168160
}
169-
161+
170162
// Check if the key already exists using getKeyPtr
171163
if (self.map.getKeyPtr(key)) |existing_key| {
172164
// Key exists, use the existing allocated key
@@ -1011,8 +1003,6 @@ pub fn Pack(
10111003
}
10121004
}
10131005

1014-
// TODO: add timestamp
1015-
10161006
fn readFrom(self: Self, bytes: []u8) !usize {
10171007
return readFn(self.read_context, bytes);
10181008
}

0 commit comments

Comments
 (0)