Skip to content

Commit

Permalink
🔨 🎉 use cache for user and group, gain 60% improve
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Zhang <[email protected]>
  • Loading branch information
zwpaper committed Apr 1, 2024
1 parent 69b28bf commit 7008079
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 87 deletions.
109 changes: 54 additions & 55 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::flags::blocks::Block;
use crate::git_theme::GitTheme;
#[cfg(target_os = "windows")]
use terminal_size::terminal_size;
use users::UsersCache;

Check failure on line 22 in src/core.rs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, i686-pc-windows-gnu)

unresolved import `users`

Check failure on line 22 in src/core.rs

View workflow job for this annotation

GitHub Actions / Style (windows-latest)

unresolved import `users`

Check failure on line 22 in src/core.rs

View workflow job for this annotation

GitHub Actions / Style (windows-latest)

unresolved import `users`

Check failure on line 22 in src/core.rs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, i686-pc-windows-msvc)

unresolved import `users`

Check failure on line 22 in src/core.rs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, x86_64-pc-windows-msvc)

unresolved import `users`

Check failure on line 22 in src/core.rs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, x86_64-pc-windows-gnu)

unresolved import `users`

pub struct Core {
flags: Flags,
Expand Down Expand Up @@ -171,9 +172,14 @@ impl Core {
}

fn display(&self, metas: &[Meta]) {
let users = UsersCache::new();
let groups = UsersCache::new();

let output = if self.flags.layout == Layout::Tree {
display::tree(
metas,
&users,
&groups,
&self.flags,
&self.colors,
&self.icons,
Expand All @@ -182,6 +188,8 @@ impl Core {
} else {
display::grid(
metas,
&users,
&groups,
&self.flags,
&self.colors,
&self.icons,
Expand Down
Loading

0 comments on commit 7008079

Please sign in to comment.