Skip to content

Miscellaneous improvements and minor optimizations

Not sure what handle limit to pass into ftw(). I picked 16 arbitrarily.

Since I changed the call to ftw(), I decided to rethink how .desktop directory scanning is currently done.

What are the effects of traversing the directory tree in findXDGDirectories() (at startup time) rather than loadXDGDirectories() (also called on .desktop rescan)? It might be faster, since we only do a recursive rescan once, but it's flawed since we don't pick up changes to which directories are present.

One theoretical advantage of having a recursive directory scan, followed by a linear file scan, is that if XDG_DATA_DIRS contains both a directory and its child, we won't process those .desktop files twice. But in practice we can avoid duplicated files (and also be more standards-conformant, link) by not appending /usr/local/share and /usr/share if we find a non-empty XDG_DATA_DIRS.

Perhaps in a future PR, we should:

  • (possibly) move the contents of findXDGDirectories() to loadXDGDirectories() and always run it.
  • (possibly) remove the logic to remove duplicate directories.
  • Stop appending duplicate "/usr/local/share" and "/usr/share" if $XDG_DATA_DIRS is set.
  • If $XDG_DATA_HOME is set, use it instead of ~"/.local/share".
  • Rewrite findXDGDirectories() and loadXDGDirectories() to not sort the directory list, and prioritize earlier directories in $XDG_DATA_DIRS.
Edited by nyanpasu64

Merge request reports

Loading