Skip to content

Commit

Permalink
Merge pull request #173 from cfxegbert/perfect-hash
Browse files Browse the repository at this point in the history
feat: Use perfect hash tables for file types and icons
  • Loading branch information
cafkafk committed Sep 3, 2023
2 parents c0391ab + e5cf097 commit de256b5
Show file tree
Hide file tree
Showing 6 changed files with 851 additions and 720 deletions.
99 changes: 99 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ log = "0.4"
natord = "1.0"
num_cpus = "1.16"
number_prefix = "0.4"
phf = { version = "0.11.2", features = ["macros"]}
scoped_threadpool = "0.1"
term_grid = "0.1"
terminal_size = "0.2.6"
Expand Down
16 changes: 0 additions & 16 deletions src/fs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,22 +662,6 @@ impl<'dir> File<'dir> {
}
}

/// Whether this file’s extension is any of the strings that get passed in.
///
/// This will always return `false` if the file has no extension.
pub fn extension_is_one_of(&self, choices: &[&str]) -> bool {
match &self.ext {
Some(ext) => choices.contains(&&ext[..]),
None => false,
}
}

/// Whether this file’s name, including extension, is any of the strings
/// that get passed in.
pub fn name_is_one_of(&self, choices: &[&str]) -> bool {
choices.contains(&&self.name[..])
}

/// This file’s security context field.
pub fn security_context(&self) -> f::SecurityContext<'_> {
let context = match &self.extended_attributes.iter().find(|a| a.name == "security.selinux") {
Expand Down
Loading

0 comments on commit de256b5

Please sign in to comment.