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

Unified Diff: Source/wtf/OwnArrayPtr.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 | « no previous file | Source/wtf/OwnPtr.h » ('j') | Source/wtf/OwnPtr.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/OwnArrayPtr.h
diff --git a/Source/wtf/OwnArrayPtr.h b/Source/wtf/OwnArrayPtr.h
index a678159e096f6222d0ef67f281a4adac0eb68cff..ad39900f552f0ac0e7890145065f1fc7f8007758 100644
--- a/Source/wtf/OwnArrayPtr.h
+++ b/Source/wtf/OwnArrayPtr.h
@@ -104,19 +104,17 @@ template<typename T> inline typename OwnArrayPtr<T>::PtrType OwnArrayPtr<T>::lea
template<typename T> inline OwnArrayPtr<T>& OwnArrayPtr<T>::operator=(const PassOwnArrayPtr<T>& o)
{
- PtrType ptr = m_ptr;
- m_ptr = o.leakPtr();
- ASSERT(!ptr || m_ptr != ptr);
- deleteOwnedArrayPtr(ptr);
+ ASSERT(!o || o != m_ptr);
+ OwnArrayPtr ptr = o;
+ swap(ptr);
return *this;
}
template<typename T> template<typename U> inline OwnArrayPtr<T>& OwnArrayPtr<T>::operator=(const PassOwnArrayPtr<U>& o)
{
- PtrType ptr = m_ptr;
- m_ptr = o.leakPtr();
- ASSERT(!ptr || m_ptr != ptr);
- deleteOwnedArrayPtr(ptr);
+ ASSERT(!o || o != m_ptr);
+ OwnArrayPtr ptr = o;
+ swap(ptr);
return *this;
}
« no previous file with comments | « no previous file | Source/wtf/OwnPtr.h » ('j') | Source/wtf/OwnPtr.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698