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

Slightly more efficient heap functions in heap.go #56827

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lorenzotinfena
Copy link

Sorry I think I duplicated (2 times) this pr, I'm noob.
I have done only a little benchmark, but maybe not coverings all possible cases.
In my benchmark (initialize a a heap) was faster around of 3-4% with this code.

@gopherbot
Copy link

This PR (HEAD: 0055dd6) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/451835 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@ishwar00
Copy link
Contributor

//
// !h.Less(j, i) for 0 <= i < h.Len() and 2*i+1 <= j <= 2*i+2 and j < h.Len()
//

Hey @lorenzotinfena, please update the comments accordingly.

Thanks

@lorenzotinfena
Copy link
Author

Hi, sorry but I don't know what you mean. It seems right to me that comment.
Maybe to be more precise (to count int overflow) I think it can be:
!h.Less(j, i) for 0 <= i < h.Len() and 2*i+1 <= j <= 2*i+2 and 0 <= j < h.Len()

@gopherbot
Copy link

Message from Subham Sarkar:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/451835.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Subham Sarkar:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/451835.
After addressing review feedback, remember to publish your drafts!

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.

None yet

3 participants