Replies: 1 comment
-
Good question. If there is a reason not to use /cc @CJ-Johnson |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I noticed that
InlinedVector
'sStorage::Insert
uses an explicit loop to move elements when making space for the inserted elements:abseil-cpp/absl/container/internal/inlined_vector.h
Lines 799 to 808 in dc242cc
I'm curious if there is something about this code that requires the explicit loop rather than using
std::move_backward
. I can see thatstd::move_backward
was used prior to ad1485c which was about improving the exception safety ofinsert
. It's not clear to me whether the explicit loop is required for some subtle reason or if the use ofstd::move_backward
just got lost during the exception safety refactoring.The motivation behind this question is that both libc++ and libstdc++ have optimizations within
std::move_backward
that support lowering tomemmove
when it is appropriate for the types involved. Using it significantly speeds upinsert
on vectors of trivial types such as integers. It completely addresses the poorinsert
performance relative to other inline capacity vectors that others have observed.Beta Was this translation helpful? Give feedback.
All reactions