2018-08-08 François Dumont <fdumont@gcc.gnu.org>
authorFrançois Dumont <fdumont@gcc.gnu.org>
Wed, 8 Aug 2018 20:28:21 +0000 (20:28 +0000)
committerFrançois Dumont <fdumont@gcc.gnu.org>
Wed, 8 Aug 2018 20:28:21 +0000 (20:28 +0000)
* 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
libstdc++-v3/include/bits/stl_algo.h

index 0bbc7f9e2c6e013a601b9458122efffb89bb127b..20e03a1fdf5a083f4df04695a99e4c191f8e2ee0 100644 (file)
@@ -1,3 +1,17 @@
+2018-08-08  François Dumont  <fdumont@gcc.gnu.org>
+
+       * 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  <jwakely@redhat.com>
 
        * libsupc++/new_opa.cc (aligned_alloc): Declare inside namespace to
index e68ba7c1807cefd9a76b7b7e7c01e3c2d693033c..e2388b0780db8bdbcca8d224947d6581cb9d6d22 100644 (file)
@@ -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<typename _ForwardIterator, typename _Predicate>
@@ -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,