Skip to content

Conversation

@camshaft
Copy link
Contributor

@camshaft camshaft commented Jun 21, 2023

Description of changes:

While implementing the XDP functionality, I needed a way to zip up slices of slices and iterate over each item. This could be accomplished with head.iter().chain(tail).zip(head2.iter_mut().chain(tail2)). However, this is a bit slow and we already have an optimized slices of slices iterator in vectored_copy.

This change refactors the vectored_copy iteration functionality into a separate zip_chunks function. This function accepts a callback for each pair of overlapping slices. The vectored_copy function now uses this to implement the copy. I've also added a simple zip function which operates on single items.

Testing:

The bolero/kani tests for the vectored_copy should verify all of the safety in the underlying function.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@camshaft camshaft marked this pull request as ready for review June 21, 2023 19:38
@camshaft camshaft merged commit 83aa162 into main Jun 21, 2023
@camshaft camshaft deleted the camshaft/slice-zip branch June 21, 2023 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants