Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

less allocations in parse_svcb_ip #41

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

jrouaix
Copy link
Contributor

@jrouaix jrouaix commented Dec 5, 2024

This small PR change the parse_svcb_ip function impl.
It's a little more complicated (sorry for that), but reduce the number of allocations :

n4 : number of ipv4 addresses
n6 : number of ipv6 addresses

Before : 2 + n4 + n6 + 2 + 1 (2 vecs + to_string for IPs + 2 joins + format!)
After (best case) : 2 + 1 (2 string buffers + format! in the end)

In the worst case, if there are many many ip addresses, String growth will reallocate the buffers, so it might be not that interesting.

What is the expected/usual number of ip addresses here ?

@jrouaix jrouaix marked this pull request as ready for review December 5, 2024 08:48
@puffyCid
Copy link
Collaborator

PR looks fine, thanks!

What is the expected/usual number of ip addresses here ?

i do not know the typical number.

@puffyCid puffyCid merged commit ba314c1 into mandiant:main Dec 10, 2024
4 checks passed
@jrouaix jrouaix deleted the parse_svcb_ip_less_allocations branch December 12, 2024 09:27
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