Simplify the code in optimized extend#316
Merged
Merged
Conversation
Use std::hint::black_box (From Rust 1.6x), and use it more; this should make the benchmarks at least a little bit more representative.
Keeping an eye on the benchmarks, simplify the optimization in extend_from_iter; use a simpler scope guard. Use a counted index. Previously there was a ZST special case which is not needed because: `ptr` is a valid pointer for writing and `ptr.add(index)` still too; `.write(elt)` consumes the element. (Previous implementation: ptr was an out of bounds pointer for ZST.) Benchmarks found to be sensitive to the order of predicates in `if index == end && CHECK` which shouldn't be the case, but it was. extend_from_iter: use only I: Iterator - reduce generics already in `extend`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Simplify the code, revitalize the benchmarks (try to), while it should preserve the optimizations used.
Developed in the discussion of #315.