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

resize is slow #45

Open
jeremy-coulon opened this issue Mar 31, 2023 · 0 comments
Open

resize is slow #45

jeremy-coulon opened this issue Mar 31, 2023 · 0 comments

Comments

@jeremy-coulon
Copy link

jeremy-coulon commented Mar 31, 2023

Hello,

Would it be possible to improve complexity of circular_buffer<T>::resize(new_size, item) in the case where T is scalar ?

Currently, complexity is always linear.

It would be nice to have constant complexity when T is a scalar type and no reallocation happens (ie. new_size <= capacity()).

When we want to reduce size of buffer (ie. new_size < size()), you could call erase_end(n) internally which already implements an optimization for scalar types.

When we want to increase size of buffer, you could optimize for scalar types by calling std::memset() at most 2 times.

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

No branches or pull requests

1 participant