Skip to content

Commit 01a354e

Browse files
author
Stephan Dilly
committed
fix preallocation
1 parent 5ed5ec1 commit 01a354e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/tabs/revlog/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ use tui::{
2424
};
2525
use utils::{ItemBatch, LogEntry};
2626

27-
static SLICE_SIZE: usize = 1200;
27+
const SLICE_SIZE: usize = 1200;
28+
const ELEMENTS_PER_LINE: usize = 10;
29+
2830
///
2931
pub struct Revlog {
3032
selection: usize,
@@ -174,8 +176,6 @@ impl Revlog {
174176
tags: Option<String>,
175177
theme: &Theme,
176178
) {
177-
const ELEMENTS_PER_LINE: usize = 10;
178-
179179
txt.reserve(ELEMENTS_PER_LINE);
180180

181181
let splitter_txt = Cow::from(" ");
@@ -229,7 +229,7 @@ impl Revlog {
229229
fn get_text(&self, height: usize) -> Vec<Text> {
230230
let selection = self.relative_selection();
231231

232-
let mut txt = Vec::with_capacity(height);
232+
let mut txt = Vec::with_capacity(height * ELEMENTS_PER_LINE);
233233

234234
for (idx, e) in self
235235
.items

0 commit comments

Comments
 (0)