Bug 1435634: Don't make the dispatch of resize events look into the observer list twice unnecessarily. r?hiro
Just something I noticed while sneaking into
bug 1435634.
RemoveElement returns whether the element was actually removed, so no need to
use Contains to bail out.
MozReview-Commit-ID: FryHBV66yRV
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -1866,20 +1866,19 @@ nsRefreshDriver::Tick(int64_t aNowEpoch,
observers.AppendElements(mResizeEventFlushObservers);
for (uint32_t i = observers.Length(); i; --i) {
if (!mPresContext || !mPresContext->GetPresShell()) {
break;
}
// Make sure to not process observers which might have been removed
// during previous iterations.
nsIPresShell* shell = observers[i - 1];
- if (!mResizeEventFlushObservers.Contains(shell)) {
+ if (!mResizeEventFlushObservers.RemoveElement(shell)) {
continue;
}
- mResizeEventFlushObservers.RemoveElement(shell);
shell->FireResizeEvent();
}
/*
* The timer holds a reference to |this| while calling |Notify|.
* However, implementations of |WillRefresh| are permitted to destroy
* the pres context, which will cause our |mPresContext| to become
* null. If this happens, we must stop notifying observers.