stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r355174 - /incubator/stdcxx/trunk/include/vector
Date Thu, 08 Dec 2005 19:11:48 GMT
Author: sebor
Date: Thu Dec  8 11:11:43 2005
New Revision: 355174

URL: http://svn.apache.org/viewcvs?rev=355174&view=rev
Log:
2005-12-08  Martin Sebor  <sebor@roguewave.com>

	* vector (swap): Optimized for unequal allocators.

Modified:
    incubator/stdcxx/trunk/include/vector

Modified: incubator/stdcxx/trunk/include/vector
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/include/vector?rev=355174&r1=355173&r2=355174&view=diff
==============================================================================
--- incubator/stdcxx/trunk/include/vector (original)
+++ incubator/stdcxx/trunk/include/vector Thu Dec  8 11:11:43 2005
@@ -627,13 +627,19 @@
     }
     else {   // not exception-safe
 
-        // avoid passing the whole objects to other vecto member
-        // functions in case they are implemented in terms of
-        // swap(); use iterators instead
+        // avoid passing the whole object to other vector member
+        // functions (i.e., assign()) in case they are implemented
+        // in terms of swap(); use iterators instead
 
-        vector __tmp (begin (), end ());
-        assign (__other.begin (), __other.end ());
-        __other.assign (__tmp.begin (), __tmp.end ());
+        vector __tmp (__other.get_allocator ());
+
+        // assert that the copy of the allocator compares equal
+        // to the original (otherwise the swap() below will cause
+        // a recursive call)
+        _RWSTD_ASSERT (__tmp.get_allocator () == __other.get_allocator ());
+
+        __tmp.assign (begin (), end ());
+        __other.swap (__tmp);
     }
 }
 



Mime
View raw message