-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Vec/Str need an efficient way to shift() multi-items #12884
Comments
The ring buffer type offers O(1) indexing, O(1) pop from both ends and O(1) amortized append to both ends so I don't think there should be many uses of a vector this way. The vector type is as good as it's going to get without it becoming another data structure. It just makes sure there's reserved space (much like |
shift() is very bad in performance, and it removes only one item at a time. if you shift() multiple times, ... |
Ah, so you want a method to shift more than one at once. It might be useful, although I still think we should be encouraging use of ring buffers :P. |
This could be |
@huonw More generally, how about |
in the PR #12976, I can't find an efficient/safe way to remove the utf-8 BOM header from source string, to avoid copy/alloc/realloc-ing memory. |
Today, changes like this would require an RFC, so if you're interested in proposing these methods, you should write one up. :) |
Vec::drain now provides this! |
Use large stack on expander thread I have verified that this fixes rust-lang#12884 for me. Hat tip to `@bjorn3` for identifying the cause of the issue.
Only run `suboptimal_flops` on inherent method calls Fixes rust-lang#12881 `suboptimal_flops` was making the wrong assumption that a `.log()` method call on a float literal must choose the inherent log method that will always have an argument present (in which case `args[0]` indexing would be fine), but that wasn't the case in the linked issue because at the point of the method call, the exact float type hadn't been inferred yet (and method selection can't select inherent methods when the exact float type has not yet been inferred, in which case it falls back to looking for trait impls and chooses the one that didn't have any parameters). This fixes it by actually making sure it's a call to an inherent method (could also fix the linked ICE by simply using fallibly indexing via `.get()`, but this felt like it'd fix the root cause: even if there were one argument, it would still be wrong to emit a warning there because it's not the `log` method the lint was expecting). I'm not sure if we need that extra function be in `clippy_utils` but it feels like it could be useful. changelog: Fixes an ICE in [`suboptimal_flops`]
to avoid copy/alloc/realloc memory.
in C or unsafe code, you just need to offset the
data
pointer andlen-=n
.The text was updated successfully, but these errors were encountered: