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

Revamp buffer providers #188

Open
Morwenn opened this issue May 24, 2021 · 0 comments
Open

Revamp buffer providers #188

Morwenn opened this issue May 24, 2021 · 0 comments
Labels
Milestone

Comments

@Morwenn
Copy link
Owner

Morwenn commented May 24, 2021

Currently the user-facing buffer providers suffer from poor decisions from the early days: they default-construct a buffer of elements, then the algorithms using buffer providers move elements to those. This design has a few issues:

  • Buffered sorters don't work with elements that are not default-constructible.
  • When the types are default-constructible but the operation is not trivial, we pay the cost of default construction for every element of the buffer, no matter whether it ends up being used or not.
  • Building a compatible buffer provider that allows default-constructible types would incur some additional overhead (see Add a buffer type for non-default-constructible types #59).

I think that the right solution is to let the buffer providers allocate the storage for enough elements, but the buffered sorters should construct and destroy the elements in the buffer as needed instead of just performing moves. This would definitely be a breaking change, so it's not something to do on the branch 1.x, but rather something to plan for 2.0.0.

The new design makes the new buffer providers look awfully like allocators, but a few design differences might make them too difficult to use properly with allocators, so I don't really want to merge them unless there is a well-motivated demand for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant