Skip to content

Commit

Permalink
Cache sorter on Core.
Browse files Browse the repository at this point in the history
  • Loading branch information
aldhsu committed Jan 9, 2020
1 parent 6896fad commit ede9735
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/core.rs
Expand Up @@ -20,6 +20,7 @@ pub struct Core {
icons: Icons,
//display: Display,
colors: Colors,
sorter: sort::Sorter,
}

impl Core {
Expand Down Expand Up @@ -59,11 +60,14 @@ impl Core {
inner_flags.layout = Layout::OneLine;
};

let sorter = sort::create_sorter(&flags);

Self {
flags,
//display: Display::new(inner_flags),
colors: Colors::new(color_theme),
icons: Icons::new(icon_theme),
sorter,
}
}

Expand Down Expand Up @@ -124,8 +128,7 @@ impl Core {
}

fn sort(&self, metas: &mut Vec<Meta>) {
let sorter = sort::create_sorter(&self.flags);
metas.sort_unstable_by(|a, b| (sorter)(a, b));
metas.sort_unstable_by(|a, b| (self.sorter)(a, b));

for meta in metas {
if let Some(ref mut content) = meta.content {
Expand Down

0 comments on commit ede9735

Please sign in to comment.