-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Make SortedMap::new
const, also faster is_empty
#56969
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
r? @davidtwco (rust_highfive has picked a reviewer for you, use r? to override) |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
b1a39d1
to
0e57f26
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
0e57f26
to
ef5423b
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
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.
While these can be const fn, we've previously opted not to make internal functions const fn without concrete use cases
@@ -30,7 +30,7 @@ pub struct SortedMap<K: Ord, V> { | |||
|
|||
impl<K: Ord, V> SortedMap<K, V> { | |||
#[inline] | |||
pub fn new() -> SortedMap<K, V> { | |||
pub const fn new() -> SortedMap<K, V> { | |||
SortedMap { | |||
data: vec![] |
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.
You need to use Vec::new()
here
ef5423b
to
0e6d1e9
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
0e6d1e9
to
2430870
Compare
☔ The latest upstream changes (presumably #56613) made this pull request unmergeable. Please resolve the merge conflicts. |
I'm all in favour of replacing |
ping from triage @davidtwco can you review this? |
I've been checking regularly to see if the conflicts have been resolved before reviewing. |
Okay. Updated the label to reflect the state. |
This is more trouble than it's worth. Closing. |
(The latter is because
[T]::is_empty
compiles to a single pointer comparison, whereaslen() == 0
first subtracts the pointers and only then compares with zero)