Bug 121154

Summary: OwnPtr: Use copy/move-and-swap for assignment operators
Product: WebKit Reporter: Mikhail Pozdnyakov <mikhail.pozdnyakov>
Component: Web Template FrameworkAssignee: Mikhail Pozdnyakov <mikhail.pozdnyakov>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, benjamin, cmarcelo, commit-queue, darin, kling
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
patch andersca: review+, andersca: commit-queue-

Description Mikhail Pozdnyakov 2013-09-11 05:17:57 PDT
Rationals:
- decrease of repeated code
- consistency with RefPtr
Comment 1 Mikhail Pozdnyakov 2013-09-11 06:33:59 PDT
Created attachment 211306 [details]
patch
Comment 2 Anders Carlsson 2013-09-11 07:17:16 PDT
Comment on attachment 211306 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=211306&action=review

> Source/WTF/wtf/OwnPtr.h:140
> -        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);

I wouldn't worry about modifying PassOwnPtr since then plan is to get rid of it.

> Source/WTF/wtf/OwnPtr.h:148
> -        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);

Ditto.

> Source/WTF/wtf/OwnPtr.h:166
> +        OwnPtr ptr = std::move(o);

Can just use auto here.

> Source/WTF/wtf/OwnPtr.h:174
> +        OwnPtr ptr = std::move(o);

Ditto.
Comment 3 Mikhail Pozdnyakov 2013-09-11 07:32:22 PDT
Committed r155526: <http://trac.webkit.org/changeset/155526>