Changeset 155526 in webkit


Ignore:
Timestamp:
Sep 11, 2013 7:33:00 AM (11 years ago)
Author:
mikhail.pozdnyakov@intel.com
Message:

OwnPtr: Use copy/move-and-swap for assignment operators
https://bugs.webkit.org/show_bug.cgi?id=121154

Reviewed by Anders Carlsson.

Rationals:

  • decrease of repeated code
  • consistency with RefPtr
  • wtf/OwnPtr.h:

(WTF::=):

Location:
trunk/Source/WTF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r155521 r155526  
     12013-09-11  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
     2
     3        OwnPtr: Use copy/move-and-swap for assignment operators
     4        https://bugs.webkit.org/show_bug.cgi?id=121154
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Rationals:
     9        - decrease of repeated code
     10        - consistency with RefPtr
     11
     12        * wtf/OwnPtr.h:
     13        (WTF::=):
     14
    1152013-09-11  Patrick Gansterer  <paroga@webkit.org>
    216
  • trunk/Source/WTF/wtf/OwnPtr.h

    r155407 r155526  
    165165    template<typename T> inline OwnPtr<T>& OwnPtr<T>::operator=(OwnPtr<T>&& o)
    166166    {
    167         PtrType ptr = m_ptr;
    168         m_ptr = o.leakPtr();
    169         ASSERT(!ptr || m_ptr != ptr);
    170         deleteOwnedPtr(ptr);
    171 
     167        ASSERT(!o || o != m_ptr);
     168        auto ptr = std::move(o);
     169        swap(ptr);
    172170        return *this;
    173171    }
     
    175173    template<typename T> template<typename U> inline OwnPtr<T>& OwnPtr<T>::operator=(OwnPtr<U>&& o)
    176174    {
    177         PtrType ptr = m_ptr;
    178         m_ptr = o.leakPtr();
    179         ASSERT(!ptr || m_ptr != ptr);
    180         deleteOwnedPtr(ptr);
    181 
     175        ASSERT(!o || o != m_ptr);
     176        auto ptr = std::move(o);
     177        swap(ptr);
    182178        return *this;
    183179    }
Note: See TracChangeset for help on using the changeset viewer.