Skip to content

GH-49133: [C++] Remove todo asking to use assign_by_moving#49136

Open
HyukjinKwon wants to merge 1 commit intoapache:mainfrom
HyukjinKwon:GH-49133
Open

GH-49133: [C++] Remove todo asking to use assign_by_moving#49136
HyukjinKwon wants to merge 1 commit intoapache:mainfrom
HyukjinKwon:GH-49133

Conversation

@HyukjinKwon
Copy link
Member

@HyukjinKwon HyukjinKwon commented Feb 4, 2026

Rationale for this change

The TODO comment in SmallVector's move assignment operator asks whether to use assign_by_moving() instead of destroy() + move_construct(). However, using destroy() + move_construct() is faster in most of the cases by memcpy according to the benchmark I ran:

Type Elements destroy + move_construct assign_by_moving
uint8_t* 16 3.54 ns 8.71 ns
const uint8_t* 16 3.54 ns 8.71 ns
const void* 3 1.49 ns 5.00 ns
int 2 1.38 ns 5.52 ns
std::string_view 2 8.42 ns 3.78 ns
std::pair<int64_t, int64_t> 1 1.40 ns 2.16 ns
FakeArrowStruct 4 3.54 ns 6.32 ns

(I did not include the benchmark code I ran to make the pr description shorter. Can be provided upon request)

We could sophisticatedly benchmark, design and consider other cases but I believe this is not worthwhile.

What changes are included in this PR?

Removed the TODO comment.

Are these changes tested?

No I did not test.

Are there any user-facing changes?

No.

@github-actions github-actions bot added the awaiting review Awaiting review label Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review Awaiting review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant