Bug 1550633 - part9 : capture 'this' in lambda. r=jya
☠☠ backed out by 6acae89335b0 ☠ ☠
authoralwu <alwu@mozilla.com>
Thu, 23 May 2019 09:03:33 +0000
changeset 475258 afaef937598b8c46c009a0523c0fbe4ba61c6c25
parent 475257 470d8fae0461968d745100f64c23aa296f0d9a05
child 475259 b6e8370b6efb20689269602b5361406dfce1d574
push id36058
push useraciure@mozilla.com
push dateFri, 24 May 2019 03:53:25 +0000
treeherdermozilla-central@c87317c41902 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1550633
milestone69.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 1550633 - part9 : capture 'this' in lambda. r=jya There are too many `self` used in the lambda, we can just capture `this` to remove redudant `self`. Differential Revision: https://phabricator.services.mozilla.com/D31558
dom/html/HTMLTrackElement.cpp
--- a/dom/html/HTMLTrackElement.cpp
+++ b/dom/html/HTMLTrackElement.cpp
@@ -340,42 +340,41 @@ void HTMLTrackElement::LoadResource(RefP
   Document* doc = OwnerDoc();
   if (!doc) {
     return;
   }
 
   // 9. End the synchronous section, continuing the remaining steps in parallel.
   nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction(
       "dom::HTMLTrackElement::LoadResource",
-      [self = RefPtr<HTMLTrackElement>(this), uri, secFlags]() {
-        if (!self->mListener) {
+      [self = RefPtr<HTMLTrackElement>(this), this, uri, secFlags]() {
+        if (!mListener) {
           // Shutdown got called, abort.
           return;
         }
         nsCOMPtr<nsIChannel> channel;
-        nsCOMPtr<nsILoadGroup> loadGroup =
-            self->OwnerDoc()->GetDocumentLoadGroup();
+        nsCOMPtr<nsILoadGroup> loadGroup = OwnerDoc()->GetDocumentLoadGroup();
         nsresult rv = NS_NewChannel(getter_AddRefs(channel), uri,
-                                    static_cast<Element*>(self), secFlags,
+                                    static_cast<Element*>(this), secFlags,
                                     nsIContentPolicy::TYPE_INTERNAL_TRACK,
                                     nullptr,  // PerformanceStorage
                                     loadGroup);
 
         NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
 
-        channel->SetNotificationCallbacks(self->mListener);
+        channel->SetNotificationCallbacks(mListener);
 
         LOG(LogLevel::Debug, ("opening webvtt channel"));
-        rv = channel->AsyncOpen(self->mListener);
+        rv = channel->AsyncOpen(mListener);
 
         if (NS_FAILED(rv)) {
-          self->SetReadyState(TextTrackReadyState::FailedToLoad);
+          SetReadyState(TextTrackReadyState::FailedToLoad);
           return;
         }
-        self->mChannel = channel;
+        mChannel = channel;
       });
   doc->Dispatch(TaskCategory::Other, runnable.forget());
 }
 
 nsresult HTMLTrackElement::BindToTree(Document* aDocument, nsIContent* aParent,
                                       nsIContent* aBindingParent) {
   nsresult rv =
       nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);