From 01a354e171ee0683028ee7b49d6520776e61d576 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Sun, 24 May 2020 13:16:11 +0200 Subject: [PATCH] fix preallocation --- src/tabs/revlog/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tabs/revlog/mod.rs b/src/tabs/revlog/mod.rs index a8e10cc8..abde8257 100644 --- a/src/tabs/revlog/mod.rs +++ b/src/tabs/revlog/mod.rs @@ -24,7 +24,9 @@ use tui::{ }; use utils::{ItemBatch, LogEntry}; -static SLICE_SIZE: usize = 1200; +const SLICE_SIZE: usize = 1200; +const ELEMENTS_PER_LINE: usize = 10; + /// pub struct Revlog { selection: usize, @@ -174,8 +176,6 @@ impl Revlog { tags: Option, theme: &Theme, ) { - const ELEMENTS_PER_LINE: usize = 10; - txt.reserve(ELEMENTS_PER_LINE); let splitter_txt = Cow::from(" "); @@ -229,7 +229,7 @@ impl Revlog { fn get_text(&self, height: usize) -> Vec { let selection = self.relative_selection(); - let mut txt = Vec::with_capacity(height); + let mut txt = Vec::with_capacity(height * ELEMENTS_PER_LINE); for (idx, e) in self .items