From 7f9e3e419c24ba51e80a4c41bcbefc820f7e0a88 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sat, 7 Nov 2020 20:30:13 +0100 Subject: [PATCH] Use @reduce --- lib/std/crypto/utils.zig | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/std/crypto/utils.zig b/lib/std/crypto/utils.zig index f6dc44e7c6..33ad6360f6 100644 --- a/lib/std/crypto/utils.zig +++ b/lib/std/crypto/utils.zig @@ -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);