Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1643)

Unified Diff: Source/wtf/OwnPtr.h

Issue 23440024: OwnPtr, OwnArrayPtr: Use copy/move-and-swap for assignment operators Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed the change in the *existing* C++11 code. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/wtf/OwnArrayPtr.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/OwnPtr.h
diff --git a/Source/wtf/OwnPtr.h b/Source/wtf/OwnPtr.h
index e5baf9341e8ae4ff56e68536d470c6dedbfb087b..023311c03c9489613f81852a9e7aef8b2e7a17b8 100644
--- a/Source/wtf/OwnPtr.h
+++ b/Source/wtf/OwnPtr.h
@@ -137,19 +137,17 @@ namespace WTF {
template<typename T> inline OwnPtr<T>& OwnPtr<T>::operator=(const PassOwnPtr<T>& o)
{
- PtrType ptr = m_ptr;
- m_ptr = o.leakPtr();
- ASSERT(!ptr || m_ptr != ptr);
- deleteOwnedPtr(ptr);
+ ASSERT(!o || o != m_ptr);
+ OwnPtr ptr = o;
+ swap(ptr);
return *this;
}
template<typename T> template<typename U> inline OwnPtr<T>& OwnPtr<T>::operator=(const PassOwnPtr<U>& o)
{
- PtrType ptr = m_ptr;
- m_ptr = o.leakPtr();
- ASSERT(!ptr || m_ptr != ptr);
- deleteOwnedPtr(ptr);
+ ASSERT(!o || o != m_ptr);
+ OwnPtr ptr = o;
+ swap(ptr);
return *this;
}
@@ -166,21 +164,17 @@ namespace WTF {
template<typename T> inline OwnPtr<T>& OwnPtr<T>::operator=(OwnPtr<T>&& o)
{
- PtrType ptr = m_ptr;
- m_ptr = o.leakPtr();
- ASSERT(!ptr || m_ptr != ptr);
- deleteOwnedPtr(ptr);
-
+ ASSERT(!o || o != m_ptr);
+ OwnPtr ptr = std::move(o);
Nico 2013/09/11 18:00:36 As mentioned several times, we can't use C++11 lib
+ swap(ptr);
return *this;
}
template<typename T> template<typename U> inline OwnPtr<T>& OwnPtr<T>::operator=(OwnPtr<U>&& o)
{
- PtrType ptr = m_ptr;
- m_ptr = o.leakPtr();
- ASSERT(!ptr || m_ptr != ptr);
- deleteOwnedPtr(ptr);
-
+ ASSERT(!o || o != m_ptr);
+ OwnPtr ptr = std::move(o);
+ swap(ptr);
return *this;
}
#endif
« no previous file with comments | « Source/wtf/OwnArrayPtr.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698