Bug 1499727 - make nsHtml5StreamParser timers slightly more efficient; r=hsivonen
authorNathan Froyd <froydnj@mozilla.com>
Wed, 17 Oct 2018 19:57:36 -0400
changeset 500337 fd914881db604175bdd129d62ec1cb3c8d0a0386
parent 500336 706f1a7eae882e297e85322e4dccba27a222e4a0
child 500338 18c94f6d82046c4986c0c55f41a6fbf4039c8288
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsivonen
bugs1499727
milestone64.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 1499727 - make nsHtml5StreamParser timers slightly more efficient; r=hsivonen Instead of creating a timer and then setting the timer's target, we can determine the timer's target and pass it in directly when the timer is created. This reordering of steps is slightly more efficient, since SetTarget() is both a virtual call and requires locking, both of which can be skipped if we know the target at timer creation time.
parser/html/nsHtml5StreamParser.cpp
--- a/parser/html/nsHtml5StreamParser.cpp
+++ b/parser/html/nsHtml5StreamParser.cpp
@@ -172,24 +172,23 @@ nsHtml5StreamParser::nsHtml5StreamParser
   , mInterrupted(false)
   , mTerminatedMutex("nsHtml5StreamParser mTerminatedMutex")
   , mEventTarget(nsHtml5Module::GetStreamParserThread()->SerialEventTarget())
   , mExecutorFlusher(new nsHtml5ExecutorFlusher(aExecutor))
   , mLoadFlusher(new nsHtml5LoadFlusher(aExecutor))
   , mFeedChardet(false)
   , mInitialEncodingWasFromParentFrame(false)
   , mHasHadErrors(false)
-  , mFlushTimer(NS_NewTimer())
+  , mFlushTimer(NS_NewTimer(mEventTarget))
   , mFlushTimerMutex("nsHtml5StreamParser mFlushTimerMutex")
   , mFlushTimerArmed(false)
   , mFlushTimerEverFired(false)
   , mMode(aMode)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-  mFlushTimer->SetTarget(mEventTarget);
 #ifdef DEBUG
   mAtomTable.SetPermittedLookupEventTarget(mEventTarget);
 #endif
   mTokenizer->setInterner(&mAtomTable);
   mTokenizer->setEncodingDeclarationHandler(this);
 
   if (aMode == VIEW_SOURCE_HTML || aMode == VIEW_SOURCE_XML) {
     nsHtml5Highlighter* highlighter =