Refactor SocketIterator for allocation-free performance - #945
Merged
Merged
Conversation
Refactor SocketIterator to eliminate boxing and improve memory efficiency. Update documentation and tests to reflect changes.
Contributor
Author
|
@bee-san for your review please |
…example - clone_resumes_independently expected None after 3 of 4 sockets; assert the exact remaining sequence for both the original and the clone. - The struct doc example referenced a placeholder crate and a private module, so it could never compile as a doctest; mark it ignore. - Add a test for empty IP/port inputs covering size_hint and the FusedIterator promise.
bee-san
approved these changes
Oct 1, 2026
bee-san
left a comment
Owner
There was a problem hiding this comment.
Thanks @syed-ghufran-hassan, nice cleanup! Dropping the Boxes and delegating size_hint is a clear win.
What I checked:
- Same sockets, same order: it's still
iproduct!(ports, ips), so every IP for one port comes before the next port, with nothing dropped or duplicated. 0 IPs or 0 ports yields nothing, andsize_hintuses itertools' saturating/checked math, so large ranges can't overflow or panic. - No new network side effects. The iterator only builds
SocketAddrs, and the call sites inscanner/mod.rsare unchanged. cargo fmt --check,clippy -D warningsandcargo docare clean, and CI is green on all 4 platforms.
I pushed one small fix commit (065ae7c) to get CI passing. clone_resumes_independently expected None while one socket was still left (2×2 = 4, one consumed before the clone, so 3 remain). The struct doc example imported your_crate and lives in a private module, so it could never compile as a doctest; I marked it ignore. I also added a small test for empty inputs.
Contributor
Author
|
Thank you @bee-san |
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.
Refactor SocketIterator to eliminate boxing and improve memory efficiency. Update documentation and tests to reflect changes.