aboutsummaryrefslogtreecommitdiff
path: root/src/grid/storage.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/grid/storage.rs')
-rw-r--r--src/grid/storage.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/grid/storage.rs b/src/grid/storage.rs
index a50e8076..1f71b5b5 100644
--- a/src/grid/storage.rs
+++ b/src/grid/storage.rs
@@ -67,9 +67,18 @@ impl<T: PartialEq> ::std::cmp::PartialEq for Storage<T> {
impl<T> Storage<T> {
#[inline]
- pub fn with_capacity(cap: usize, lines: Line) -> Storage<T> {
+ pub fn with_capacity(cap: usize, lines: Line, template: T) -> Storage<T>
+ where
+ T: Clone,
+ {
+ // Allocate all lines in the buffer, including scrollback history
+ //
+ // 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.
+ let inner = vec![template; cap];
Storage {
- inner: Vec::with_capacity(cap),
+ inner,
zero: 0,
visible_lines: lines - 1,
len: cap,
@@ -121,11 +130,6 @@ impl<T> Storage<T> {
}
#[inline]
- pub fn push(&mut self, item: T) {
- self.inner.push(item)
- }
-
- #[inline]
pub fn len(&self) -> usize {
self.len
}