authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2020-11-07 20:30:13+01:00
committergravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2020-11-07 20:30:13+01:00
log7f9e3e419c24ba51e80a4c41bcbefc820f7e0a88
treeeef5e8a18461047e6efe838a1a2f16b57200a3f4
parentbd07154242664e9d25ba60333e1a497562aa7c27

Use @reduce


1 files changed, 1 insertions(+), 6 deletions(-)

lib/std/crypto/utils.zig+1-6
......@@ -26,12 +26,7 @@ pub fn timingSafeEql(comptime T: type, a: T, b: T) bool {
2626 if (@typeInfo(C) != .Int) {
2727 @compileError("Elements to be compared must be integers");
2828 }
29 const z = a ^ b;
30 var acc = @as(C, 0);
31 var i: usize = 0;
32 while (i < info.len) : (i += 1) {
33 acc |= z[i];
34 }
29 const acc = @reduce(.Or, a ^ b);
3530 comptime const s = @typeInfo(C).Int.bits;
3631 comptime const Cu = std.meta.Int(.unsigned, s);
3732 comptime const Cext = std.meta.Int(.unsigned, s + 1);