Low-hanging fruit optimization in string::__move_assign().
authorVedant Kumar <vsk@apple.com>
Thu, 8 Mar 2018 21:15:26 +0000 (21:15 +0000)
committerVedant Kumar <vsk@apple.com>
Thu, 8 Mar 2018 21:15:26 +0000 (21:15 +0000)
commitfb36d079e57cf56819bfbc1a1c2c8282accb58d5
treee6c0479098c548f7401804fc5f5580c7573ea0ee
parent145bc6e0d35cc456d5f0239d22566190780b057e
Low-hanging fruit optimization in string::__move_assign().

shrink_to_fit() ends up doing a lot work to get information that we
already know since we just called clear(). This change seems concise
enough to be worth the couple extra lines and my benchmarks show that it
is indeed a pretty decent win. It looks like the same thing is going on
twice in __copy_assign_alloc(), but I didn't want to go overboard since
this is my first contribution to llvm/libc++.

Patch by Timothy VanSlyke!

Differential Revision: https://reviews.llvm.org/D41976

llvm-svn: 327064
libcxx/include/string
libcxx/test/libcxx/strings/basic.string/string.modifiers/clear_and_shrink_db1.pass.cpp [new file with mode: 0644]