Small optimization

This commit is contained in:
daa 2017-09-11 22:00:26 +03:00
parent 945cea6acf
commit 8b15361a84

View File

@ -186,18 +186,17 @@ impl Line {
self.cell_to_item[cell_idx] self.cell_to_item[cell_idx]
} }
pub fn item_len_from_idx(&self, mut start_idx: usize) -> usize { pub fn item_len_from_idx(&self, start_idx: usize) -> usize {
let mut len = 1; debug_assert!(start_idx < self.line.len());
start_idx += 1;
while start_idx < self.item_line.len() && self.is_binded_to_item(start_idx) && let item_idx = self.cell_to_item(start_idx);
self.item_line[start_idx].is_none()
{ if item_idx >= 0 {
start_idx += 1; let item_idx = item_idx as usize;
len += 1; self.item_line[item_idx].as_ref().unwrap().cells_count - (start_idx - item_idx)
} else {
1
} }
len
} }
#[inline] #[inline]