libstdc++: Optimize basic_string move assignment
authorFrançois Dumont <fdumont@gcc.gnu.org>
Wed, 4 Jan 2023 18:34:21 +0000 (19:34 +0100)
committerFrançois Dumont <fdumont@gcc.gnu.org>
Sat, 4 Feb 2023 13:03:54 +0000 (14:03 +0100)
commit540a22d243966d1b882db26b17fe674467e2a169
tree3d5616980078acbf6d95ed2f778b91d566d6bb87
parent49e52115b09b477382fef6f04fd7b4d1641f902c
libstdc++: Optimize basic_string move assignment

Since resolution of Issue 2593 [1] we can consider that equal allocators
before the propagate-on-move-assignment operations will still be equal
afterward.

So we can extend the optimization of transfering the storage of the move-to
instance to the move-from one that is currently limited to always equal
allocators.

[1] https://cplusplus.github.io/LWG/issue2593

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h (operator=(basic_string&&)): Transfer move-to
storage to the move-from instance when allocators are equal.
* testsuite/21_strings/basic_string/allocator/char/move_assign.cc (test04):
New test case.
libstdc++-v3/include/bits/basic_string.h
libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/move_assign.cc