This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] Remove last two iterator postincrement


Hi,

tested x86-linux, committed to mainline.

Paolo.

//////////////
2004-10-07  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/list.tcc (operator=): Avoid iterator postincrement.
	* include/bits/stl_tree.h (erase(iterator, iterator)): Likewise.
diff -urN libstdc++-v3-orig/include/bits/list.tcc libstdc++-v3/include/bits/list.tcc
--- libstdc++-v3-orig/include/bits/list.tcc	2004-08-03 12:11:31.000000000 +0200
+++ libstdc++-v3/include/bits/list.tcc	2004-10-07 23:30:58.000000000 +0200
@@ -125,8 +125,9 @@
 	  iterator __last1 = end();
 	  const_iterator __first2 = __x.begin();
 	  const_iterator __last2 = __x.end();
-	  while (__first1 != __last1 && __first2 != __last2)
-	    *__first1++ = *__first2++;
+	  for (; __first1 != __last1 && __first2 != __last2;
+	       ++__first1, ++__first2)
+	    *__first1 = *__first2;
 	  if (__first2 == __last2)
 	    erase(__first1, __last1);
 	  else
diff -urN libstdc++-v3-orig/include/bits/stl_tree.h libstdc++-v3/include/bits/stl_tree.h
--- libstdc++-v3-orig/include/bits/stl_tree.h	2004-10-03 17:50:32.000000000 +0200
+++ libstdc++-v3/include/bits/stl_tree.h	2004-10-07 23:49:24.000000000 +0200
@@ -1087,7 +1087,8 @@
       if (__first == begin() && __last == end())
 	clear();
       else
-	while (__first != __last) erase(__first++);
+	for (; __first != __last; ++__first)
+	  erase(__first);
     }
 
   template<typename _Key, typename _Val, typename _KeyOfValue,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]