You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm curious if there is something about this code that requires the explicit loop rather than using std::move_backward. I can see that std::move_backward was used prior to ad1485c which was about improving the exception safety of insert. It's not clear to me whether the explicit loop is required for some subtle reason or if the use of std::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 to memmove when it is appropriate for the types involved. Using it significantly speeds up insert on vectors of trivial types such as integers. It completely addresses the poor insert performance relative to other inline capacity vectors that others have observed.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
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