-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
New article: VecDeque::resize() optimization #7
Conversation
lgtm |
Hi, @scottmcm, would you mind reviewing my article? Thanks. ❤️ |
Came over this and I'm curious, does |
Hi, can you explain how |
Created running example at https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=fd82d81d0f485acd769c3b0aaeeb5a3b |
Another version of that
Godbolt says this can be optimized to 2 branches, which I assume corresponds to 2 special cases for count == 0 and count == 1, i.e. second |
Good question! I actually tried that first. I wasn't able to get it to optimize as nicely, though. I think it might be because that's essentially Definitely give it a shot and see if you can make it work, though! I'd love to get rid of all the |
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.
Look reasonable to me!
One thing you might consider adding is a bit more about why not cloning is useful. Probably doesn't need to be a huge section, but it might be worth a mention, or an example in which you can tell between different rust versions that something different is happening.
(For extra credit, consider when you might want the buffer to be reused and what code you're write to do that instead.)
@scottmcm your playground link tests for |
@XeCycle I did that on purpose to show the niche behaviour -- you'll notice the The goal is to show that |
@scottmcm Ahh sorry, missed your point. Thanks a lot, now I get it that you want the |
Co-authored-by: scottmcm <scottmcm@users.noreply.github.com>
Rarely is anything strictly 🙂 One thing that the merged implementation doesn't allow is a (AKA every niche is also a constraint.) |
I added an alternative section.
I have no idea how to add something about why not cloning is useful. Can you give some suggestions? Thanks. @scottmcm |
Hi, @scottmcm, do you mind giving another review? We plan to release the first issue end of January. 😄 |
No description provided.