Explore potential for optimization in array::insert(Iter, InputIt, InputIt)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- cpp
- Domain
- performance
Research direction
Start at array::insert(Iter, InputIt, InputIt) and trace its buffer-growth and exception-guarantee paths. Evaluate the proposed end-fill, temporary-buffer, relocation, and rotation cases; done means avoiding even temporary allocation when existing capacity fits while preserving the strong guarantee.
Written by the indexing model from the issue text.
Description
The idea is this:
- Fill the buffer up to capacity at the end (needs a
revert_insertprotection). - Create a temporary buffer with the remaining elements (can throw).
- If temporary buffer is not empty
- Allocate new buffer with necessary size (can throw).
- 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.
- If the temporary buffer is empty, rotate elements in the original buffer instead.
In the end result:
- 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. - We should be able to keep the strong guarantee.
- Dominant language
- C++
- Stars
- 479
- Forks
- 110
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/json
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
boostorg/json#1196 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
boostorg/json#1162 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
boostorg/json#1155 · 1 comment ·
Maintainers usually reply within 1 day
-
sanitizer warningOpen
Difficulty 3/5 1-2 days Newbie friendliness 45/100
boostorg/json#1133 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
WebAssembly/binaryen#9207 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
godotengine/godot#124139 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
ChicoState/autovalidate#195 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
petercorke/robotics-toolbox-python#709 ·
Maintainers usually reply within 2 days