| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reser
ved. | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reser
ved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 template <typename U> PassRefPtr(RefPtr<U>&&, EnsurePtrConvertibleArgDecl(U,
T)); | 75 template <typename U> PassRefPtr(RefPtr<U>&&, EnsurePtrConvertibleArgDecl(U,
T)); |
| 76 | 76 |
| 77 T* get() const { return m_ptr; } | 77 T* get() const { return m_ptr; } |
| 78 | 78 |
| 79 T* leakRef() const WARN_UNUSED_RETURN; | 79 T* leakRef() const WARN_UNUSED_RETURN; |
| 80 | 80 |
| 81 T& operator*() const { return *m_ptr; } | 81 T& operator*() const { return *m_ptr; } |
| 82 T* operator->() const { return m_ptr; } | 82 T* operator->() const { return m_ptr; } |
| 83 | 83 |
| 84 bool operator!() const { return !m_ptr; } | 84 bool operator!() const { return !m_ptr; } |
| 85 | 85 explicit operator bool() const { return m_ptr != nullptr; } |
| 86 // TODO(jbroman): Simplifying this in the obvious way causes a massive | |
| 87 // regression in a perf test on ARM. http://crbug.com/607208 | |
| 88 explicit operator bool() const { return m_ptr ? &PassRefPtr::m_ptr : 0; } | |
| 89 | 86 |
| 90 friend PassRefPtr adoptRef<T>(T*); | 87 friend PassRefPtr adoptRef<T>(T*); |
| 91 | 88 |
| 92 private: | 89 private: |
| 93 enum AdoptRefTag { AdoptRef }; | 90 enum AdoptRefTag { AdoptRef }; |
| 94 PassRefPtr(T* ptr, AdoptRefTag) : m_ptr(ptr) {} | 91 PassRefPtr(T* ptr, AdoptRefTag) : m_ptr(ptr) {} |
| 95 | 92 |
| 96 PassRefPtr& operator=(const PassRefPtr&) | 93 PassRefPtr& operator=(const PassRefPtr&) |
| 97 { | 94 { |
| 98 static_assert(!sizeof(T*), "PassRefPtr should never be assigned to"); | 95 static_assert(!sizeof(T*), "PassRefPtr should never be assigned to"); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 return p.get(); | 206 return p.get(); |
| 210 } | 207 } |
| 211 | 208 |
| 212 } // namespace WTF | 209 } // namespace WTF |
| 213 | 210 |
| 214 using WTF::PassRefPtr; | 211 using WTF::PassRefPtr; |
| 215 using WTF::adoptRef; | 212 using WTF::adoptRef; |
| 216 using WTF::static_pointer_cast; | 213 using WTF::static_pointer_cast; |
| 217 | 214 |
| 218 #endif // WTF_PassRefPtr_h | 215 #endif // WTF_PassRefPtr_h |
| OLD | NEW |