-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
libexpr: don't allocate additional set in builtins.listToAttrs
#13387
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
Conversation
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.
Optimization LGTM. It's a bit hacky, since it slightly abuses the fact Bindings::operator[]
does not check that the access isn't out of bounds of size_
. In the future we might want a cleaner API for doing such optimizations.
In C++ the expectation is that |
Thank you @NaN-git! |
Motivation
At the moment this function uses an additional
std::set
to filter duplicate keys. This causes many additional allocations for the nodes in the set.Finally the
Bindings
are sorted, although the set contains the keys in sorted order already.Context
The additional
std::set
is not necessary. Instead theBindings
are sorted and filtered in a single array.Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.