(Failed) iterator experiment instead of multiple for loops #809
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.
Here, experiment with upgrading to Go 1.23 so we can replace a couple
hooks-related TODOs where we have two separate for loops with a single
invocation that uses an iterator to iterate two slices without an
additional slice invocation.
I'm putting this up for the sake of interest, but it unfortunately turns
out to be quite a failed experiment. The iterators work, but using them
is slower than both the previous two
for
loops, and also slower thanjust allocating a new slice with the contents of the previous two and
iterating that.
At larger slice sizes, the iterator becomes marginally faster than
allocating a new slice, but only marginally. Using two for loops
continues to be bit a bit faster (perhaps unsurprisingly).
Anyway, opened this for general interest, but am going to close it, and
probably just replace the two for loops with a slice allocation, since
it looks nicer and it's the fastest option for small slices sizes (and
we generally expect hooks to be relatively small slices).