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

fish: replace use of tr with string split #90670

Merged
merged 2 commits into from Jun 18, 2020
Merged

Conversation

bouk
Copy link
Contributor

@bouk bouk commented Jun 17, 2020

This shaves about 4ms off fish start time. It also makes it more clear what's happening.

Before (profiled with 'fish --profile prof.txt -c fish_prompt'):

225	4636	----> set -l __nix_profile_paths (echo $NIX_PROFILES | /nix/store/m5ajgnzp2512na31brwfmydwk3l1gawb-coreutils-8.31/bin/tr ' ' '\n')[-1..1]
4411	4411	-----> echo $NIX_PROFILES | /nix/store/m5ajgnzp2512na31brwfmydwk3l1gawb-coreutils-8.31/bin/tr ' ' '\n'

After:

190	248	----> set -l __nix_profile_paths (string split ' ' $NIX_PROFILES)[-1..1]

Also use -p when expanding the profile paths, to make it clear we are
prepending.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Copy link
Member

@cole-h cole-h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diff LGTM, builds and runs fine.

However, I'd like to ask that you split your changes into two commits, fish: replace tr with builtin string split and fish: prepend paths in fishPreInitHooks, since they are two unrelated changes (I'm bad at doing this myself).

[3 built, 0.0 MiB DL]
https://github.com/NixOS/nixpkgs/pull/90670
1 package built:
fish

bouk added 2 commits June 17, 2020 18:59
This shaves about 4ms off fish start time.

Before (profiled with 'fish --profile prof.txt -c fish_prompt'):

225	4636	----> set -l __nix_profile_paths (echo $NIX_PROFILES | /nix/store/m5ajgnzp2512na31brwfmydwk3l1gawb-coreutils-8.31/bin/tr ' ' '\n')[-1..1]
4411	4411	-----> echo $NIX_PROFILES | /nix/store/m5ajgnzp2512na31brwfmydwk3l1gawb-coreutils-8.31/bin/tr ' ' '\n'

After:

190	248	----> set -l __nix_profile_paths (string split ' ' $NIX_PROFILES)[-1..1]
@bouk
Copy link
Contributor Author

bouk commented Jun 17, 2020

You're right, I've split the commit in two

@ofborg ofborg bot requested a review from cole-h June 17, 2020 17:08
Copy link
Contributor

@rnhmjoj rnhmjoj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and fish works as expected.

@rnhmjoj rnhmjoj merged commit b253217 into NixOS:master Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants