-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
DedupAddrs should not allocate #2323
Comments
I just wanted to fix the comment. |
Are you sure there’s a performance penalty for a O(N^2) for small N? I’d expect it to be negligible for typical values of N. |
I think you're right. These are the benchmarks for an O(N^2) implementation:
Even if a node has 100 addrs(my kubo node has 15 before deduping), this isn't prohibitively expensive. These are the numbers for the current implementation:
|
There's https://pkg.go.dev/golang.org/x/exp/slices, which provides allocation-free sorting. I created #2395 to make use of that package. |
Sort.Slice will allocate unfortunately :(
golang/go#17332
Originally posted by @sukunrt in #2322 (comment)
The text was updated successfully, but these errors were encountered: