diff options
author | Joe Wilm <joe@jwilm.com> | 2018-05-19 14:47:16 -0700 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2018-06-02 09:56:50 -0700 |
commit | 169b87e4ce19f4fd22e5d06ff27f9d3d0ee19b44 (patch) | |
tree | 04fbe139a5bda9dbbfb02d9ead2cacea3718f314 /src/grid/mod.rs | |
parent | 5a11f8584317b6a949a1ff3a5b3a446766db0665 (diff) | |
download | alacritty-169b87e4ce19f4fd22e5d06ff27f9d3d0ee19b44.tar.gz alacritty-169b87e4ce19f4fd22e5d06ff27f9d3d0ee19b44.zip |
Shave a few cycles off Grid::scroll_up
This implementation avoids a few extra transformations by operating in
buffer-space. However, there is still a transformation from the logical
buffer-space to the underlying vector.
Diffstat (limited to 'src/grid/mod.rs')
-rw-r--r-- | src/grid/mod.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/grid/mod.rs b/src/grid/mod.rs index 9b36fcdf..0998d640 100644 --- a/src/grid/mod.rs +++ b/src/grid/mod.rs @@ -334,7 +334,6 @@ impl<T: Copy + Clone> Grid<T> { /// scroll_up moves lines at the bottom towards the top /// /// This is the performance-sensitive part of scrolling. - #[inline] pub fn scroll_up( &mut self, region: &Range<index::Line>, @@ -356,17 +355,21 @@ impl<T: Copy + Clone> Grid<T> { selection.rotate(*positions as isize); } - // Now, restore any lines outside the scroll region - for idx in (*region.end .. *self.num_lines()).rev() { - // First do the swap - self.raw.swap_lines(Line(idx), Line(idx) - positions); + // // This next loop swaps "fixed" lines outside of a scroll region + // // back into place after the rotation. The work is done in buffer- + // // space rather than terminal-space to avoid redundant + // // transformations. + let fixed_lines = *self.num_lines() - *region.end; + + for i in 0..fixed_lines { + self.raw.swap(i, i + *positions); } // Finally, reset recycled lines // // Recycled lines are just above the end of the scrolling region. for i in 0..*positions { - self.raw[region.end - i - 1].reset(&template); + self.raw[i + fixed_lines].reset(&template); } } else { // Subregion rotation |