aboutsummaryrefslogtreecommitdiff
path: root/libcxx/include/algorithm
diff options
context:
space:
mode:
authorKonstantin Varlamov <varconst@apple.com>2022-10-01 17:28:57 -0700
committerKonstantin Varlamov <varconst@apple.com>2022-10-01 17:35:12 -0700
commit005916de58f73aa5c4264c084ba7b0e21040d88f (patch)
tree8c1147716db984d8c99b0032389216d1652f63b6 /libcxx/include/algorithm
parent240f41c8e45186ea8f781dad7caed789a34f215c (diff)
downloadllvm-005916de58f73aa5c4264c084ba7b0e21040d88f.zip
llvm-005916de58f73aa5c4264c084ba7b0e21040d88f.tar.gz
llvm-005916de58f73aa5c4264c084ba7b0e21040d88f.tar.bz2
[libc++][ranges]Refactor `copy{,_backward}` and `move{,_backward}`
Instead of using `reverse_iterator`, share the optimization between the 4 algorithms. The key observation here that `memmove` applies to both `copy` and `move` identically, and to their `_backward` versions very similarly. All algorithms now follow the same pattern along the lines of: ``` if constexpr (can_memmove<InIter, OutIter>) { memmove(first, last, out); } else { naive_implementation(first, last, out); } ``` A follow-up will delete `unconstrained_reverse_iterator`. This patch removes duplication and divergence between `std::copy`, `std::move` and `std::move_backward`. It also improves testing: - the test for whether the optimization is used only applied to `std::copy` and, more importantly, was essentially a no-op because it would still pass if the optimization was not used; - there were no tests to make sure the optimization is not used when the effect would be visible. Differential Revision: https://reviews.llvm.org/D130695
Diffstat (limited to 'libcxx/include/algorithm')
-rw-r--r--libcxx/include/algorithm2
1 files changed, 1 insertions, 1 deletions
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 9b21e7b..c1e098d 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -1708,7 +1708,6 @@ template <class BidirectionalIterator, class Compare>
#include <__config>
#include <__debug>
#include <cstddef>
-#include <cstring>
#include <type_traits>
#include <version>
@@ -1917,6 +1916,7 @@ template <class BidirectionalIterator, class Compare>
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <atomic>
+# include <cstring>
# include <iterator>
# include <memory>
# include <stdexcept>