stl_algo.h (search_n): Tweak, to spare the first --__n.
authorPaolo Carlini <pcarlini@unitus.it>
Tue, 30 Sep 2003 17:03:52 +0000 (19:03 +0200)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 30 Sep 2003 17:03:52 +0000 (17:03 +0000)
2003-09-30  Paolo Carlini  <pcarlini@unitus.it>

* include/bits/stl_algo.h (search_n): Tweak, to spare the
first --__n.

From-SVN: r71946

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_algo.h

index 410d65c24993057faea7deacc951d9848060c208..662541a202f83e7f25c5bac7a0d05ba62fc3b91a 100644 (file)
@@ -1,3 +1,8 @@
+2003-09-30  Paolo Carlini  <pcarlini@unitus.it>
+
+       * include/bits/stl_algo.h (search_n): Tweak, to spare the
+       first --__n.
+
 2003-09-30  Paolo Carlini  <pcarlini@unitus.it>
 
        * testsuite/22_locale/locale/cons/12352.cc: Explicitly
index c92aa3c35438691bc820d7aae7d8946dacb76a3e..c2fb87117c01265548947e92f4cef13f5ee390f0 100644 (file)
@@ -610,14 +610,13 @@ namespace std
        __first = std::find(__first, __last, __val);
        while (__first != __last) {
          typename iterator_traits<_ForwardIterator>::difference_type __n = __count;
-         --__n;
          _ForwardIterator __i = __first;
          ++__i;
-         while (__i != __last && __n != 0 && *__i == __val) {
+         while (__i != __last && __n != 1 && *__i == __val) {
            ++__i;
            --__n;
          }
-         if (__n == 0)
+         if (__n == 1)
            return __first;
          else
            __first = std::find(__i, __last, __val);
@@ -663,14 +662,13 @@ namespace std
        }
        while (__first != __last) {
          typename iterator_traits<_ForwardIterator>::difference_type __n = __count;
-         --__n;
          _ForwardIterator __i = __first;
          ++__i;
-         while (__i != __last && __n != 0 && __binary_pred(*__i, __val)) {
+         while (__i != __last && __n != 1 && __binary_pred(*__i, __val)) {
            ++__i;
            --__n;
          }
-         if (__n == 0)
+         if (__n == 1)
            return __first;
          else {
            while (__i != __last) {