mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
Use @reduce
This commit is contained in:
parent
bd07154242
commit
7f9e3e419c
@ -26,12 +26,7 @@ pub fn timingSafeEql(comptime T: type, a: T, b: T) bool {
|
||||
if (@typeInfo(C) != .Int) {
|
||||
@compileError("Elements to be compared must be integers");
|
||||
}
|
||||
const z = a ^ b;
|
||||
var acc = @as(C, 0);
|
||||
var i: usize = 0;
|
||||
while (i < info.len) : (i += 1) {
|
||||
acc |= z[i];
|
||||
}
|
||||
const acc = @reduce(.Or, a ^ b);
|
||||
comptime const s = @typeInfo(C).Int.bits;
|
||||
comptime const Cu = std.meta.Int(.unsigned, s);
|
||||
comptime const Cext = std.meta.Int(.unsigned, s + 1);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user