-
Notifications
You must be signed in to change notification settings - Fork 20.2k
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
p2p/discover: improve nodesByDistance.push #26019
Conversation
I don't get it. Is there a bug in the current version? |
No bug here, but I think the comment is not accurate, multiple cases are coerced into one. For example, in the |
I think the change is harder to understand than before the change. |
|
0db7fc1
to
2484548
Compare
This improves readability of function 'push'. sort.Search(N, ...) will at most return N when no match, so ix should be compared with N. The previous version would compare ix with N+1 in case an additional item was appended. No bug resulted from this comparison, but it's not easy to understand why. Co-authored-by: Felix Lange <[email protected]>
This improves readability of function 'push'. sort.Search(N, ...) will at most return N when no match, so ix should be compared with N. The previous version would compare ix with N+1 in case an additional item was appended. No bug resulted from this comparison, but it's not easy to understand why. Co-authored-by: Felix Lange <[email protected]>
Spotted this days ago, today I was writing something similar and I decide to create a PR for this.
It just doesn't feel right to check
ix == len(h.entries)
after possibly appending an additional entry toh.entries
.@fjl correct me if there's something missed out:)