Skip to content

Commit 5ed5ec1

Browse files
author
Stephan Dilly
committed
optimizations
1 parent 08f4fae commit 5ed5ec1

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/tabs/revlog/mod.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,21 +182,31 @@ impl Revlog {
182182
let splitter =
183183
Text::Styled(splitter_txt, theme.text(true, selected));
184184

185+
// commit hash
185186
txt.push(Text::Styled(
186187
Cow::from(&e.hash[0..7]),
187188
theme.commit_hash(selected),
188189
));
190+
189191
txt.push(splitter.clone());
192+
193+
// commit timestamp
190194
txt.push(Text::Styled(
191195
Cow::from(e.time.as_str()),
192196
theme.commit_time(selected),
193197
));
198+
194199
txt.push(splitter.clone());
200+
201+
// commit author
195202
txt.push(Text::Styled(
196203
Cow::from(e.author.as_str()),
197204
theme.commit_author(selected),
198205
));
206+
199207
txt.push(splitter.clone());
208+
209+
// commit tags
200210
txt.push(Text::Styled(
201211
Cow::from(if let Some(tags) = tags {
202212
format!(" {}", tags)
@@ -205,7 +215,10 @@ impl Revlog {
205215
}),
206216
theme.tab(true).bg(theme.text(true, selected).bg),
207217
));
218+
208219
txt.push(splitter);
220+
221+
// commit msg
209222
txt.push(Text::Styled(
210223
Cow::from(e.msg.as_str()),
211224
theme.text(true, selected),
@@ -216,7 +229,7 @@ impl Revlog {
216229
fn get_text(&self, height: usize) -> Vec<Text> {
217230
let selection = self.relative_selection();
218231

219-
let mut txt = Vec::new();
232+
let mut txt = Vec::with_capacity(height);
220233

221234
for (idx, e) in self
222235
.items
@@ -230,6 +243,7 @@ impl Revlog {
230243
} else {
231244
None
232245
};
246+
233247
Self::add_entry(
234248
e,
235249
idx + self.scroll_top == selection,

0 commit comments

Comments
 (0)