mirror of
https://github.com/flatpak/flatpak.git
synced 2026-06-26 17:26:50 -04:00
Sourcing profile/flatpak.fish spawns `flatpak --installations` on every fish shell startup, which costs ~15 ms on a typical desktop and dominates fish's non-interactive init time when flatpak is installed. On any system where the login stack (pam_env, systemd user session, distro-specific init) has already populated XDG_DATA_DIRS with the canonical user flatpak export path, this spawn is redundant: the subsequent `contains` loop would be a no-op because the canonical entry is already there. Add a fast-path guard that checks for `$XDG_DATA_HOME/flatpak/exports/share` (falling back to `$HOME/.local/share/flatpak/exports/share` when XDG_DATA_HOME is unset) at the top of the script. When present, skip the slow path entirely. The slow path is preserved verbatim for sessions where the canonical entry is missing — e.g. a freshly-created user, or environments where session init hasn't populated XDG_DATA_DIRS yet — so custom installations configured via /etc/flatpak/installations.d/*.conf are still discovered in that case. Measured on Linux with `hyperfine --warmup 5 'fish -c exit'`: before: ~23 ms of startup spent in `flatpak --installations` after: ~10 us (a single `contains` check) on the common path.