mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1665373 - Bail earlier if getting a null ref to NS_ReleaseOnMainThread. r=sg
This is just a minor optimization, not intended to change behavior. Differential Revision: https://phabricator.services.mozilla.com/D90398
This commit is contained in:
parent
29b27e6d30
commit
47f53144a5
@ -149,6 +149,11 @@ template <class T>
|
||||
inline NS_HIDDEN_(void)
|
||||
NS_ReleaseOnMainThread(const char* aName, already_AddRefed<T> aDoomed,
|
||||
bool aAlwaysProxy = false) {
|
||||
RefPtr<T> doomed = aDoomed;
|
||||
if (!doomed) {
|
||||
return; // Nothing to do.
|
||||
}
|
||||
|
||||
// NS_ProxyRelease treats a null event target as "the current thread". So a
|
||||
// handle on the main thread is only necessary when we're not already on the
|
||||
// main thread or the release must happen asynchronously.
|
||||
@ -158,12 +163,12 @@ inline NS_HIDDEN_(void)
|
||||
|
||||
if (!target) {
|
||||
MOZ_ASSERT_UNREACHABLE("Could not get main thread; leaking an object!");
|
||||
mozilla::Unused << aDoomed.take();
|
||||
mozilla::Unused << doomed.forget().take();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
NS_ProxyRelease(aName, target, std::move(aDoomed), aAlwaysProxy);
|
||||
NS_ProxyRelease(aName, target, doomed.forget(), aAlwaysProxy);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
Loading…
Reference in New Issue
Block a user