Skip to content

Commit

Permalink
implement #24 for simd code path (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
alindima authored Dec 6, 2023
1 parent 5e06a05 commit 18d5b10
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions reed-solomon-novelpoly/src/field/inc_encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,21 +243,17 @@ pub fn encode_sub_faster8(bytes: &[u8], n: usize, k: usize) -> Result<Vec<Additi
assert!(is_power_of_2(upper_len));
assert!(upper_len >= bytes_len);

// tuple_windows are only used here
// tuples are only used here
use itertools::Itertools;

// pad the incoming bytes with trailing 0s
// so we get a buffer of size `N` in `GF` symbols
let zero_bytes_to_add = n * 2 - bytes_len;
let elm_data = Vec::<Additive>::from_iter(
bytes
.iter()
.copied()
.chain(std::iter::repeat(0u8).take(zero_bytes_to_add))
.tuple_windows()
.step_by(2)
.map(|(a,b)| Additive(Elt::from_be_bytes([a, b])))
);
let mut elm_data = Vec::with_capacity(n);
let zeros = std::iter::repeat(&0u8).take(zero_bytes_to_add);
for (first, second) in bytes.iter().chain(zeros).tuples() {
elm_data.push(Additive(Elt::from_be_bytes([*first, *second])));
}

// update new data bytes with zero padded bytes
// `l` is now `GF(2^16)` symbols
Expand Down

0 comments on commit 18d5b10

Please sign in to comment.