Skip to content

Commit b3ad9d8

Browse files
committed
Fix and refactor indexOfDiff
1 parent f0f0733 commit b3ad9d8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/std/mem.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,8 @@ fn indexOfDiffBytes(a: []const u8, b: []const u8) ?usize {
844844
return mask != 0;
845845
}
846846
inline fn firstDiff(mask: Mask) usize {
847-
return @ctz(mask);
847+
// Endian-aware
848+
return if (native_endian == .little) @ctz(mask) else @clz(mask);
848849
}
849850
} else struct { // SWAR path
850851
const size = @sizeOf(usize);

0 commit comments

Comments
 (0)