aboutsummaryrefslogtreecommitdiff
path: root/src/grid/mod.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2018-04-30 00:22:15 +0200
committerChristian Duerr <contact@christianduerr.com>2018-04-30 00:41:21 +0200
commit946ef1e3067daef4b8131d5cc7c8d87175465e0a (patch)
treea48207aa1a20e7714e1b8f625ec6dfdf9a911972 /src/grid/mod.rs
parentcf23f56999bee9884de81cd7e046e9a53ebb1632 (diff)
downloadalacritty-946ef1e3067daef4b8131d5cc7c8d87175465e0a.tar.gz
alacritty-946ef1e3067daef4b8131d5cc7c8d87175465e0a.zip
Improve the resizing implementation
Until now the resizing implementation with scrollback has been really inefficient because it made use of APIs like `Vec::insert`. This has been rewored with this commit. A `len` property has been added to the `Storage` struct which keeps track of the actual length of the raw buffer. This has changed both shrinking and growing implementations. With shrinking, no more lines are removed, only the `len` property is updated to set all lines shrunk to an "invisible" state which cannot be accessed from the outside, this effectively changes it to a O(1) operation. The only issue with this would be memory consumption, but since the maximum shrinkage is the number of lines on one screen, it should be a rather small impacte (probabl <100 lines usually). If desired it would be possible to change this to shrink the raw inner buffer whenever there are more than X lines hidden. Growing now works in a similar way to shrinking, if the "invisible" lines are enough, no new lines are inserted but rather the invisible buffer is made visible again. Otherwise the amount of lines that still needs to be inserted is added to the raw buffer, but instead of the inefficient `Vec::insert`, the `Vec::push` API is used now. This fixes #1271.
Diffstat (limited to 'src/grid/mod.rs')
-rw-r--r--src/grid/mod.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/grid/mod.rs b/src/grid/mod.rs
index ac54f580..13e6cc00 100644
--- a/src/grid/mod.rs
+++ b/src/grid/mod.rs
@@ -121,7 +121,7 @@ impl<T: Copy + Clone> Grid<T> {
// TODO (jwilm) Allocating each line at this point is expensive and
// delays startup. A nice solution might be having `Row` delay
// allocation until it's actually used.
- for _ in 0..raw.capacity() {
+ for _ in 0..raw.len() {
raw.push(Row::new(cols, &template));
}