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

Sort preferences by environment, then index #10700

Merged
merged 1 commit into from
Jan 17, 2025
Merged

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Jan 17, 2025

Summary

This has a few effects:

  1. We only call preferences once, which should be more efficient.
  2. We collect preferences into a vector when there are multiple. Less efficient, but pretty rare?
  3. We now correctly prefer preferences from the same index.

@charliermarsh charliermarsh force-pushed the charlie/pref-sort branch 4 times, most recently from 2f76959 to 65f2417 Compare January 17, 2025 00:55
@charliermarsh charliermarsh marked this pull request as ready for review January 17, 2025 01:14
@charliermarsh charliermarsh requested a review from konstin January 17, 2025 01:14
@charliermarsh charliermarsh added the bug Something isn't working label Jan 17, 2025
Either::Left(std::iter::once((entry.marker(), entry.pin().version())))
}
[..] => {
let mut preferences = preferences.iter().collect::<Vec<_>>();
Copy link
Member

Choose a reason for hiding this comment

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

We can use a smallvec here to avoid the allocation for diverging forks (with 2 elements it's even the same size, though this is stack only anyway)

@charliermarsh charliermarsh enabled auto-merge (squash) January 17, 2025 17:17
@charliermarsh charliermarsh merged commit e02a7bb into main Jan 17, 2025
64 checks passed
@charliermarsh charliermarsh deleted the charlie/pref-sort branch January 17, 2025 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants