Skip to content

Commit 43b3137

Browse files
chrisbbreuerclaude
andcommitted
fix: simplify zig comptime_match to fix Linux test failure
Replace u48 pointer-cast integer comparison with std.mem.eql in comptime_match. The unaligned integer read via @ptrCast was failing on Linux CI (passes on macOS). The compiler optimizes std.mem.eql for small comptime-known sizes anyway. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 407681b commit 43b3137

1 file changed

Lines changed: 2 additions & 15 deletions

File tree

packages/zig-dtsx/src/scanner.zig

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,9 @@ const Declaration = types.Declaration;
88
const DeclarationKind = types.DeclarationKind;
99
const Allocator = std.mem.Allocator;
1010

11-
/// Comptime-optimized word comparison: matches N bytes via integer casts when possible.
11+
/// Comptime-optimized word comparison using std.mem.eql (compiler optimizes small sizes).
1212
inline fn comptime_match(comptime N: usize, src: *const [N]u8, comptime word: []const u8) bool {
13-
if (N <= 8) {
14-
// Pack the expected word into an integer at comptime
15-
const T = std.meta.Int(.unsigned, N * 8);
16-
const expected: T = comptime blk: {
17-
var val: T = 0;
18-
for (word, 0..) |b, i| {
19-
val |= @as(T, b) << @intCast(i * 8);
20-
}
21-
break :blk val;
22-
};
23-
return @as(*align(1) const T, @ptrCast(src)).* == expected;
24-
} else {
25-
return std.mem.eql(u8, src, word);
26-
}
13+
return std.mem.eql(u8, src, word);
2714
}
2815

2916
/// Result of scanning: declarations + non-exported types

0 commit comments

Comments
 (0)