Bug 1499849 - make FileReader timers slightly more efficient; r=baku
authorNathan Froyd <froydnj@mozilla.com>
Wed, 17 Oct 2018 19:57:35 -0400
changeset 500339 8b037400fdbed6b9fd14c36a8b32acd78a742e1d
parent 500338 18c94f6d82046c4986c0c55f41a6fbf4039c8288
child 500340 8bdbb72ad61b6272b3b7faed01383bb7c5fe7e72
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)
reviewersbaku
bugs1499849
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 1499849 - make FileReader timers slightly more efficient; r=baku 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.
dom/file/FileReader.cpp
--- a/dom/file/FileReader.cpp
+++ b/dom/file/FileReader.cpp
@@ -526,24 +526,23 @@ FileReader::WrapObject(JSContext* aCx, J
 {
   return FileReader_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 void
 FileReader::StartProgressEventTimer()
 {
   if (!mProgressNotifier) {
-    mProgressNotifier = NS_NewTimer();
+    mProgressNotifier = NS_NewTimer(mTarget);
   }
 
   if (mProgressNotifier) {
     mProgressEventWasDelayed = false;
     mTimerIsActive = true;
     mProgressNotifier->Cancel();
-    mProgressNotifier->SetTarget(mTarget);
     mProgressNotifier->InitWithCallback(this, NS_PROGRESS_EVENT_INTERVAL,
                                         nsITimer::TYPE_ONE_SHOT);
   }
 }
 
 void
 FileReader::ClearProgressEventTimer()
 {