-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Change VecDeque::new() to not use any allocation #1173
Comments
👍 as long as it can be done without significantly affecting perf. |
Maybe |
@ticki I don't think it needs a new method for it. Main issue is that I don't see an easy way to make a no allocation VecDeque into a valid state that we can handle without more complicated conditionals to check capacity. I didn't spend too long time trying to implement it, though. |
Changing my mind because I didn't know about the behaviour with |
How does it violate RAII? It would only bring VecDeque into the behavior that Vec already has. |
@Undeterminant, hm, I'm missing the connection between not allocating and RAII, e.g. |
It looks like most methods go though the computation of |
Now that you mention it, you're right. I was under the assumption that all of these containers allocated on creation. |
This is completely out of cache, but I recall that |
Note that rust-lang/rust#30426 "regresses" BTreeMap to behave like VecDeque. |
I don't think that's correct? In the present code, |
@bluss Ah, I was just going off the PR's description. I've long since forgot such details :) |
Closing in favor of rust-lang/rust#68990. |
Allocation free empty collections are very useful, for example for algorithms where a large portion of its cases don't need to store any elements.
The text was updated successfully, but these errors were encountered: