-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
treewide: fold -> foldr #110742
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
treewide: fold -> foldr #110742
Conversation
cd79904
to
ae9107a
Compare
I think you missed a file and ofborg complains about that. |
ae9107a
to
e786809
Compare
The question here is whether |
|
Ok so should I go through my changes and make them - fold and true (attrValues (zipAttrsWithNames (attrNames pattern) (n: values:
+ foldr and true (attrValues (zipAttrsWithNames (attrNames pattern) (n: values: might as well be - fold and true (attrValues (zipAttrsWithNames (attrNames pattern) (n: values:
+ foldl' and true (attrValues (zipAttrsWithNames (attrNames pattern) (n: values: |
I’d argue that should use |
Looks like we need an hlint equivalent for Nix! 😆 |
but anyway, the refactor shouldn’t introduce any behaviour changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Next up, somebody should go through uses of foldr
to check whether we can gain memory or speed savings by using foldl'
instead.
cc @infinisil @grahamc there might be easy memory/speed gains here |
e786809
to
59f10c8
Compare
lib/default.nix
Outdated
@@ -79,7 +79,7 @@ let | |||
recursiveUpdate matchAttrs overrideExisting getOutput getBin | |||
getLib getDev getMan chooseDevOutputs zipWithNames zip | |||
recurseIntoAttrs dontRecurseIntoAttrs; | |||
inherit (self.lists) singleton forEach foldr fold foldl foldl' imap0 imap1 | |||
inherit (self.lists) singleton forEach fold foldr foldl foldl' imap0 imap1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to just change the position of foldr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good catch, I'll revert this.
59f10c8
to
1c2a2b0
Compare
running: before
after
Most of the numbers improve <1%, and heapSize is reduced ~3%. |
@tomberek that seems as expected, since the only gain here is saving the indirection from fold to foldr (as What might be reasonable is going through the replacements and seeing where things definitely would be equivalent under |
perhaps should be done in a separate PR as suggested by @Profpatsch |
Motivation for this change
@Profpatsch continue with the deprecation?
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)