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

Fix extra slice growth in rebuildOrderHeap #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jbowes
Copy link

@jbowes jbowes commented Sep 17, 2021

rebuildOrderHeap was allocing a slice with a len of the max required size, then
appending unbound vars to it. This resulted in a slice with nbVars entries of
'0' to start with, followed by the actual unbound vars. Adding those unbound
vars would cause slice growth.

Ultimately, all but the last leading 0 value would be ignored by the queue,
and maybe that shouldn't have been there, as that var might already have been
bound?

Replace the slice alloc len form with the cap form, so there's no leading
'0's, and append doesn't cause slice growth.

rebuildOrderHeap was allocing a slice with a len of the max required size, then
appending unbound vars to it. This resulted in a slice with nbVars entries of
'0' to start with, followed by the actual unbound vars. Adding those unbound
vars would cause slice growth.

Ultimately, all but the last leading `0` value would be ignored by the queue,
and maybe that shouldn't have been there, as that var might already have been
bound?

Replace the slice alloc `len` form with the `cap` form, so there's no leading
'0's, and append doesn't cause slice growth.
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.

1 participant