Bug 1370025 P1 Better optimize the single mFiringIdStack case in IsInvalidFiringId(). r=ehsan
authorBen Kelly <ben@wanderview.com>
Mon, 05 Jun 2017 12:42:33 -0700
changeset 410520 2c25fe3b1af68748d01e8949585a44148649552c
parent 410519 a312474c646c41b28e6ef3f4cdb7a1d45056c3df
child 410521 229af89db178767f88316ea46424e75a2f7bfe9d
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1370025
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1370025 P1 Better optimize the single mFiringIdStack case in IsInvalidFiringId(). r=ehsan
dom/base/TimeoutManager.cpp
--- a/dom/base/TimeoutManager.cpp
+++ b/dom/base/TimeoutManager.cpp
@@ -172,21 +172,24 @@ TimeoutManager::DestroyFiringId(uint32_t
 }
 
 bool
 TimeoutManager::IsInvalidFiringId(uint32_t aFiringId) const
 {
   // Check the most common ways to invalidate a firing id first.
   // These should be quite fast.
   if (aFiringId == InvalidFiringId ||
-      mFiringIdStack.IsEmpty() ||
-      (mFiringIdStack.Length() == 1 && mFiringIdStack[0] != aFiringId)) {
+      mFiringIdStack.IsEmpty()) {
     return true;
   }
 
+  if (mFiringIdStack.Length() == 1) {
+    return mFiringIdStack[0] != aFiringId;
+  }
+
   // Next do a range check on the first and last items in the stack
   // of active firing ids.  This is a bit slower.
   uint32_t low = mFiringIdStack[0];
   uint32_t high = mFiringIdStack.LastElement();
   MOZ_DIAGNOSTIC_ASSERT(low != high);
   if (low > high) {
     // If the first element is bigger than the last element in the
     // stack, that means mNextFiringId wrapped around to zero at