This is an archive of the discontinued LLVM Phabricator instance.

[ADT] Remove unnecessary copies in SmallVectorImpl::swap
Needs ReviewPublic

Authored by njames93 on Sep 14 2020, 5:39 AM.

Details

Summary

If one of the containers needs to grow to accomodate the amount of items in the other container, but the other container is in big mode, We can just swap the buffers over.
This saves copying the items between 2 known heap allocated buffers.

Diff Detail

Event Timeline

njames93 created this revision.Sep 14 2020, 5:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 14 2020, 5:39 AM
njames93 requested review of this revision.Sep 14 2020, 5:39 AM

Is this testable? It should produce fewer element copies, yes? Could you add a test for it?