Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Explore potential for optimization in array::insert(Iter, InputIt, InputIt)

未关闭
#702 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
30/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
停滞
技术栈
cpp
领域
performance

调研方向

从 array::insert(Iter, InputIt, InputIt) 开始,跟踪其缓冲区增长和异常保证路径。评估所提议的末尾填充、临时缓冲区、重定位和旋转情况;完成的标准是在现有容量足够时避免哪怕是临时分配,同时保持强保证。

由索引模型根据 Issue 内容生成。

描述

Performance

The idea is this:

  1. Fill the buffer up to capacity at the end (needs a revert_insert protection).
  2. Create a temporary buffer with the remaining elements (can throw).
  3. If temporary buffer is not empty
    1. Allocate new buffer with necessary size (can throw).
    2. Relocate elements
      • first original elements, up to insertion point,
      • then new elements (at the end of the original buffer),
      • then new elements from the temporary buffer,
      • then remaining old elements.
  4. If the temporary buffer is empty, rotate elements in the original buffer instead.

In the end result:

  1. If the original capacity could accommodate the input range, then no new buffer (even a temporary one) is allocated. This is particularly useful when the caller uses input iterators, but does know the input range size, and thus can call reserve.
  2. We should be able to keep the strong guarantee.
主要语言
C++
星标
481
派生
111
平均合并
11 天 23 小时
30 天内合并 PR
6

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

boostorg/json 的其他 Issue

查看 boostorg/json 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。