From 29a9c26c554433dd4e8010040b02e11ddbab8bd6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Dumont?= Date: Wed, 8 Aug 2018 20:28:21 +0000 Subject: [PATCH] =?utf8?q?2018-08-08=20=20Fran=C3=A7ois=20Dumont=20=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * include/bits/stl_algo.h (__rotate(_Ite, _Ite, _Ite, forward_iterator_tag)) (__rotate(_Ite, _Ite, _Ite, bidirectional_iterator_tag)) (__rotate(_Ite, _Ite, _Ite, random_access_iterator_tag)): Move code duplication... (rotate(_Ite, _Ite, _Ite)): ...here. (__stable_partition_adaptive(_FIt, _FIt, _Pred, _Dist, _Pointer, _Dist)): Simplify rotate call. (__rotate_adaptive(_BIt1, _BIt1, _BIt1, _Dist, _Dist, _Bit2, _Dist)): Likewise. (__merge_without_buffer(_BIt, _BIt, _BIt, _Dist, _Dist, _Comp)): Likewise. From-SVN: r263433 --- libstdc++-v3/ChangeLog | 14 +++++++++++ libstdc++-v3/include/bits/stl_algo.h | 35 +++++++--------------------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 0bbc7f9e2c6..20e03a1fdf5 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,17 @@ +2018-08-08 François Dumont + + * include/bits/stl_algo.h + (__rotate(_Ite, _Ite, _Ite, forward_iterator_tag)) + (__rotate(_Ite, _Ite, _Ite, bidirectional_iterator_tag)) + (__rotate(_Ite, _Ite, _Ite, random_access_iterator_tag)): Move code duplication... + (rotate(_Ite, _Ite, _Ite)): ...here. + (__stable_partition_adaptive(_FIt, _FIt, _Pred, _Dist, _Pointer, _Dist)): + Simplify rotate call. + (__rotate_adaptive(_BIt1, _BIt1, _BIt1, _Dist, _Dist, _Bit2, _Dist)): + Likewise. + (__merge_without_buffer(_BIt, _BIt, _BIt, _Dist, _Dist, _Comp)): + Likewise. + 2018-08-08 Jonathan Wakely * libsupc++/new_opa.cc (aligned_alloc): Declare inside namespace to diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index e68ba7c1807..e2388b0780d 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -1251,11 +1251,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _ForwardIterator __last, forward_iterator_tag) { - if (__first == __middle) - return __last; - else if (__last == __middle) - return __first; - _ForwardIterator __first2 = __middle; do { @@ -1296,11 +1291,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept< _BidirectionalIterator>) - if (__first == __middle) - return __last; - else if (__last == __middle) - return __first; - std::__reverse(__first, __middle, bidirectional_iterator_tag()); std::__reverse(__middle, __last, bidirectional_iterator_tag()); @@ -1334,11 +1324,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< _RandomAccessIterator>) - if (__first == __middle) - return __last; - else if (__last == __middle) - return __first; - typedef typename iterator_traits<_RandomAccessIterator>::difference_type _Distance; typedef typename iterator_traits<_RandomAccessIterator>::value_type @@ -1440,6 +1425,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_requires_valid_range(__first, __middle); __glibcxx_requires_valid_range(__middle, __last); + if (__first == __middle) + return __last; + else if (__last == __middle) + return __first; + return std::__rotate(__first, __middle, __last, std::__iterator_category(__first)); } @@ -1601,9 +1591,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __right_len, __buffer, __buffer_size); - std::rotate(__left_split, __middle, __right_split); - std::advance(__left_split, std::distance(__middle, __right_split)); - return __left_split; + return std::rotate(__left_split, __middle, __right_split); } template @@ -2402,11 +2390,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __last; } else - { - std::rotate(__first, __middle, __last); - std::advance(__first, std::distance(__middle, __last)); - return __first; - } + return std::rotate(__first, __middle, __last); } /// This is a helper function for the merge routines. @@ -2513,9 +2497,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __len11 = std::distance(__first, __first_cut); } - std::rotate(__first_cut, __middle, __second_cut); - _BidirectionalIterator __new_middle = __first_cut; - std::advance(__new_middle, std::distance(__middle, __second_cut)); + _BidirectionalIterator __new_middle + = std::rotate(__first_cut, __middle, __second_cut); std::__merge_without_buffer(__first, __first_cut, __new_middle, __len11, __len22, __comp); std::__merge_without_buffer(__new_middle, __second_cut, __last, -- 2.30.2