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.
Description
Adds a new method for
World
struct.The function extends a user-provided collection directly instead of writing to internal buffer and then giving a reference to the contents of the buffer.
Because
Vec::extend_from_slice
simply redirects toVec::extend
,World::extend
was changed to useWorld::extend_out
; there should be no performance difference.Also
World::push
usesWorld::extend_out
to avoid allocation inWorld::extend
.Motivation and Context
Mostly to allow users skip an intermediate buffer to do insertions a little bit faster.
Fixes #218.
Well, not so much of an issue fix, because the fix for the issue is really simple:
but anyway, the code could also be fixed with this new function without a cost of additional allocations.
How Has This Been Tested?
cargo test
Because
extend
andpush
use the new function, this should be enough, as every test forpush
andextend
is also a test forextend_out
.Checklist: