stl_algo.h (search_n): Tweak, to spare the first --__n.

2003-09-30  Paolo Carlini  <pcarlini@unitus.it>

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

From-SVN: r71946
This commit is contained in:
Paolo Carlini 2003-09-30 19:03:52 +02:00 committed by Paolo Carlini
parent 2ea247d376
commit cbc6c296e6
2 changed files with 9 additions and 6 deletions

View 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

View 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) {