Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use perfect hash tables for file types and icons #1229

Closed
wants to merge 18 commits into from

Conversation

cfxegbert
Copy link

@cfxegbert cfxegbert commented Aug 4, 2023

Change filetype and icon lookup to use perfect hash tables to simplify lookups.

  • Perfect hash maps are generated at compile instead of runtime avoiding the lazy_static initialization of MAP_BY_NAME. Right now the tables are directly defined in build.rs but could be easily moved to an external datafile that is read by build.rs
  • Perfect hash maps are sized to the data and do not need to allocate extra buckets that a regular hash map creates.
  • Avoid the linear searches for the file extensions in both the filetype and icon. Match statements of str does a linear walk of each pattern.
  • Remove the coupling between icon and filetype. This will allow a more specific icon to be used instead of the generic icon for filetype. For example, a file with an svg extension can use the filetype color for an image but use an icon to shows it is vector art instead of a bitmap image. As a result of removing the coupling all the filetypes for image, video, music, and lossless had to be added to the icon map. Most of them were already in the icon map.
  • Create constants for a majority of unicode icons.
  • Fix icons removed in Nerd Fonts 3.x

@cfxegbert
Copy link
Author

Added pull request #1221

@cfxegbert
Copy link
Author

Added pull request #1194 #1191 #1162 #1150 #1148 #1144 #1140 #1120 #1100 #1238 #1234

@cfxegbert
Copy link
Author

Matched icons with https://github.com/eza-community/eza

@cafkafk
Copy link

cafkafk commented Sep 1, 2023

ohh wrong pr

@ariasuni
Copy link
Collaborator

ariasuni commented Sep 6, 2023

exa is unmaintained, and this has been merged in the active fork eza, so I see no reason to keep this PR around (thanks a lot for the effort though). Also see #1243

@ariasuni ariasuni closed this Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants