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

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: Do not modify code inside "#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)" 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..61609386abaa6b23033030dcc9adfc37c3a38c16 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;
}
« 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