diff options
| author | Jack O'Connor <[email protected]> | 2024-08-18 11:16:13 -0700 |
|---|---|---|
| committer | Jack O'Connor <[email protected]> | 2024-08-18 11:32:23 -0700 |
| commit | 5c4c351a1a0729f8e7a88e6895379bb952ed1a07 (patch) | |
| tree | ae23751fbf5eaeaf394efd810fc578286022c722 /src/platform.rs | |
| parent | 4386d7f0baae5cf77e319f12256bd7c91fedc1ef (diff) | |
make xof_many fall back to compress_xof instead of portable code
Diffstat (limited to 'src/platform.rs')
| -rw-r--r-- | src/platform.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/platform.rs b/src/platform.rs index 590a77c..cd8ef63 100644 --- a/src/platform.rs +++ b/src/platform.rs @@ -282,7 +282,7 @@ impl Platform { cv: &CVWords, block: &[u8; BLOCK_LEN], block_len: u8, - counter: u64, + mut counter: u64, flags: u8, out: &mut [u8], ) { @@ -299,7 +299,16 @@ impl Platform { Platform::AVX512 => unsafe { crate::avx512::xof_many(cv, block, block_len, counter, flags, out) }, - _ => crate::portable::xof_many(cv, block, block_len, counter, flags, out), + _ => { + // For platforms without an optimized xof_many, fall back to a loop over + // compress_xof. This is still faster than portable code. + for out_block in out.chunks_exact_mut(BLOCK_LEN) { + // TODO: Use array_chunks_mut here once that's stable. + let out_array: &mut [u8; BLOCK_LEN] = out_block.try_into().unwrap(); + *out_array = self.compress_xof(cv, block, block_len, counter, flags); + counter += 1; + } + } } } |
