Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

resize is slow

Open
#45 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
performance

Research direction

Locate circular_buffer::resize(new_size, item) and read its current resizing paths alongside erase_end(n), which the issue identifies as already optimized for scalar types. Confirm the no-reallocation scalar cases and verify that shrinking and growing meet the requested complexity improvements.

Written by the indexing model from the issue text.

Description

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.

Dominant language
C++
Stars
65
Forks
64
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/circular_buffer

All issues in boostorg/circular_buffer

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.