Skip to content

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

Closed
cfxegbert wants to merge 18 commits into
ogham:masterfrom
cfxegbert:perfect-hash
Closed

feat: Use perfect hash tables for file types and icons#1229
cfxegbert wants to merge 18 commits into
ogham:masterfrom
cfxegbert:perfect-hash

Conversation

@cfxegbert

@cfxegbert cfxegbert commented Aug 4, 2023

Copy link
Copy Markdown

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
Copy Markdown
Author

Added pull request #1221

@cfxegbert

Copy link
Copy Markdown
Author

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

@cfxegbert

Copy link
Copy Markdown
Author

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

@cafkafk

cafkafk commented Sep 1, 2023

Copy link
Copy Markdown

ohh wrong pr

@ariasuni

ariasuni commented Sep 6, 2023

Copy link
Copy Markdown
Collaborator

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.

3 participants