diff --git a/src/encoder.rs b/src/encoder.rs index d3b552a..67071ad 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -77,13 +77,11 @@ pub fn calculate_block_offsets( if zs > 0 { for _ in zl..(zl + zs) { let offset = ks as usize * config.symbol_size() as usize; - if data_index + offset <= data.len() { - blocks.push((data_index, (data_index + offset))); - } else { + if data_index + offset > data.len() { // Should only be possible when Kt * T > F. See third to last paragraph in section 4.4.1.2 assert!(kt as usize * config.symbol_size() as usize > data.len()); - blocks.push((data_index, (data_index + offset))); } + blocks.push((data_index, (data_index + offset))); data_index += offset; } } diff --git a/src/iterators.rs b/src/iterators.rs index 387654c..5066e87 100644 --- a/src/iterators.rs +++ b/src/iterators.rs @@ -141,9 +141,7 @@ impl<'a> Iterator for OctetIter<'a> { if self.sparse { let elements = self.sparse_elements.unwrap(); // Need to iterate over the whole array, since they're not sorted by logical col - if self.sparse_index >= elements.len() { - return None; - } else { + if self.sparse_index < elements.len() { while self.sparse_index < elements.len() { let entry = elements.get_by_raw_index(self.sparse_index); self.sparse_index += 1; @@ -152,8 +150,8 @@ impl<'a> Iterator for OctetIter<'a> { return Some((logical_col as usize, entry.1)); } } - return None; } + return None; } else if self.dense_index == self.end_col { return None; } else {