From fcb42fe8d12780744f6c5bd90596ad8881816d94 Mon Sep 17 00:00:00 2001 From: newpavlov Date: Tue, 27 Mar 2018 19:28:37 +0300 Subject: [PATCH] do not unroll the rounds loop --- keccak/src/lib.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/keccak/src/lib.rs b/keccak/src/lib.rs index 15ec21f..8c9a41f 100644 --- a/keccak/src/lib.rs +++ b/keccak/src/lib.rs @@ -1,8 +1,5 @@ //! Keccak [sponge function](https://en.wikipedia.org/wiki/Sponge_function). //! -//! The function code is fully unrolled and is nearly as fast as the Keccak -//! team's optimized implementation. -//! //! If you are looking for SHA-3 hash functions take a look at [`sha3`][1] and //! [`tiny-keccak`][2] crates. //! @@ -140,7 +137,9 @@ macro_rules! unroll24 { pub fn f1600(a: &mut [u64; PLEN]) { let mut arrays: [[u64; 5]; 24] = [[0; 5]; 24]; - unroll24!(i, { + // not unrolling this loop results in a much smaller function, plus + // it positively influences performance due to the smaller load on I-cache + for i in 0..24 { // Theta unroll5!(x, { // This looks useless but it gets way slower without it. I tried @@ -190,5 +189,5 @@ pub fn f1600(a: &mut [u64; PLEN]) { // Iota a[0] ^= RC[i]; - }); + } }