boostorg / boostorg/json

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

オープン
#702 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る
Performance
主要言語
C++
スター
479
フォーク
110
平均マージ
10日 3時間
マージ済み PR(30日)
5

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。