From 613f8fe83fc2db4bc39f18ad1a8190d33a4a1181 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 29 Sep 2020 00:41:37 +0200 Subject: [PATCH] Use mem.copy() instead of manual iterations --- lib/std/crypto/gimli.zig | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/std/crypto/gimli.zig b/lib/std/crypto/gimli.zig index e5f93f5833..181aa1ed53 100644 --- a/lib/std/crypto/gimli.zig +++ b/lib/std/crypto/gimli.zig @@ -249,17 +249,13 @@ pub const Aead = struct { in = in[State.RATE..]; out = out[State.RATE..]; }) { - const d = in[0..State.RATE]; - for (d) |v, i| { + for (in[0..State.RATE]) |v, i| { buf[i] ^= v; } - for (d) |_, i| { - out[i] = buf[i]; - } + mem.copy(u8, out[0..State.RATE], buf[0..State.RATE]); state.permute(); } - const d = in[0..]; - for (d) |v, i| { + for (in[0..]) |v, i| { buf[i] ^= v; out[i] = buf[i]; } @@ -299,9 +295,7 @@ pub const Aead = struct { for (d) |v, i| { out[i] = buf[i] ^ v; } - for (d) |v, i| { - buf[i] = v; - } + mem.copy(u8, buf[0..State.RATE], d[0..State.RATE]); state.permute(); } for (buf[0..in.len]) |*p, i| {