]> Sergey Matveev's repositories - nnn.git/commit
Revise and optimize icons handling
authorNRK <nrk@disroot.org>
Wed, 20 Jul 2022 09:57:05 +0000 (15:57 +0600)
committerNRK <nrk@disroot.org>
Fri, 22 Jul 2022 11:08:42 +0000 (17:08 +0600)
commit3b09fd1c75980f00d031b4e3eee70212573fbf71
tree4137bf786964fab6c1ce69b0605439dce87d555b
parentd95755cce159bc55a84ced550db7edfad04ad407
Revise and optimize icons handling

This pretty much reworks the entire icon system. Some notable changes:

* The extensions are put into a statically generated hash-table instead
  of a sorted array. We use Robin-Hood insertion to reduce the max probe
  length. Currently we need to probe only 2 slots for `O_EMOJI` and only
  3 for `O_NERD`/`O_ICONS`.
* I've opted not to use a perfect-hash since the perfect hashes
  generated by [`gperf`](https://www.gnu.org/software/gperf) used some
  huge lookup table. The hash function also wasn't as minimal as I'd
  like.
* Colors are now using X-Macros. This should speed up startup since we
  don't have to search `icons_ext` linearly to find unique colors.
* The hash-table generator outputs a more space optimized `struct
  icon_pair` using a char array instead of char pointer. This brings
  down the binary size from `145KiB` when using `O_NERD` down to
  `137KiB`.
* Some unnecessary duplication and indirection has been reduced by using
  the `ICON_STR()` macro.
.gitignore
Makefile
src/icons-emoji.h [deleted file]
src/icons-hash.c [new file with mode: 0644]
src/icons-nerdfont.h [deleted file]
src/icons.h
src/nnn.c