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

ncplane_resize_internal() ought realloc when x dimension doesn't change #2425

Closed
dankamongmen opened this issue Dec 6, 2021 · 4 comments
Closed
Assignees
Labels
perf sweet sweet perf
Milestone

Comments

@dankamongmen
Copy link
Owner

See #2323. ncplane_resize_internal() ought be optimized for the case where the x dimension doesn't change -- in this case, we want to realloc() if possible, since we needn't restripe the existing data (when the x dimension does change, we ought go ahead and malloc()+copy, as we'd otherwise realloc()+restripe, where the realloc() might require a copy itself).

this is an important optimization if someone's laying out a plane that grows downward with the content. this way, we only require a copy when we actually must move (i.e. within realloc()).

@dankamongmen dankamongmen added the perf sweet sweet perf label Dec 6, 2021
@dankamongmen dankamongmen added this to the 4.0.0 milestone Dec 6, 2021
@dankamongmen dankamongmen self-assigned this Dec 6, 2021
@dankamongmen
Copy link
Owner Author

this is less trivial than it might sound...we allocate the new framebuffer early in ncplane_resize_internal(), and it's a loooong function...

also, we can only do this when the old dimx equals the new dimx, and it is equal to keeplenx.

@dankamongmen
Copy link
Owner Author

we also ought do this whenever we're not keeping anything, to avoid a potential copy there.

@dankamongmen
Copy link
Owner Author

alright, i think i've got it working...

@dankamongmen
Copy link
Owner Author

yeah, we've got this in there now.

@dankamongmen dankamongmen modified the milestones: 4.0.0, 3.1.0 Dec 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf sweet sweet perf
Projects
None yet
Development

No branches or pull requests

1 participant