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.
This commit is contained in:
Nathan Froyd 2018-10-17 19:57:36 -04:00
parent d75b9ed4bd
commit 7d5d1b760a

View File

@ -177,14 +177,13 @@ nsHtml5StreamParser::nsHtml5StreamParser(nsHtml5TreeOpExecutor* 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