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

Side by Side Diff: third_party/WebKit/Source/wtf/PassRefPtr.h

Issue 2090973002: Reland: WTF: Simplify RefPtr::operator bool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use !! Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/RefPtr.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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; }
Nico 2016/06/23 16:02:06 no !! pls
jbroman 2016/06/23 16:05:44 Windows warns (with our flags, errors) about "retu
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
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
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/RefPtr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698