llvm / llvm/llvm-project

[libc++] Algorithms like `copy` and `copy_n` can use batch insertion for insert iterators into containers

Open
#163,134 15 comments 0 reactions 0 assignees View on GitHub
libc++ performance
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

As far as I can see, its not currently handled if output iterator is a back_inserter. But it is potentially much better to do

```cpp
out._container.insert(_container.end(), b, e) // uninitialized_copy_n or smth inside
```
instead of many .push_backs

In msvc stl its also not handled, but vector of bool is special case

Contributor guide

Open the contributing guide

Research direction

Start by tracing libc++'s copy and copy_n implementations and their back_inserter or insert-iterator handling, including the vector special case mentioned in the issue. Compare the existing per-element insertion path with the proposed container batch insertion, then determine focused tests for supported containers and edge cases. Done means batching is used where valid without changing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.