Skip to content

Commit fddd185

Browse files
authored
feat: teach patches a fast path for size one slice (#4415)
1 parent 4668bad commit fddd185

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎vortex-array/src/patches.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,13 @@ impl Patches {
358358

359359
/// Slice the patches by a range of the patched array.
360360
pub fn slice(&self, range: Range<usize>) -> Option<Self> {
361+
if range.len() == 1 {
362+
let patch_index = self.search_index(range.start).to_found()?;
363+
let values = self.values.slice(patch_index..patch_index + 1);
364+
let indices = self.indices.slice(patch_index..patch_index + 1);
365+
return Some(Self::new(1, range.start + self.offset(), indices, values));
366+
}
367+
361368
let patch_start = self.search_index(range.start).to_index();
362369
let patch_stop = self.search_index(range.end).to_index();
363370

0 commit comments

Comments
 (0)