boostorg / boostorg/circular_buffer

resize is slow

Open
#45 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
65
Forks
64
PR merge metrics
No merged PRs in 30d

Description

Hello,

Would it be possible to improve complexity of `circular_buffer::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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.