Bug 1358275 - Optimize away repeated StyleContext() calls in nsBidiPresUtils::TraverseFrames. rs=dholbert
authorJonathan Kew <jkew@mozilla.com>
Wed, 26 Apr 2017 23:25:49 +0100
changeset 403215 033145d323135c10d4eb2780e18ffd7bbb17335b
parent 403214 779ea6294a225a49a7f4787ad2145fc1bef8c5cd
child 403216 dba6cd25106665ebfa440b6af8ab81c8c22126c7
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)
reviewersdholbert
bugs1358275
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 1358275 - Optimize away repeated StyleContext() calls in nsBidiPresUtils::TraverseFrames. rs=dholbert
layout/base/nsBidiPresUtils.cpp
--- a/layout/base/nsBidiPresUtils.cpp
+++ b/layout/base/nsBidiPresUtils.cpp
@@ -1074,42 +1074,42 @@ nsBidiPresUtils::TraverseFrames(nsBlockI
     if (nsGkAtoms::placeholderFrame == childFrame->GetType()) {
       nsIFrame* realFrame =
         nsPlaceholderFrame::GetRealFrameForPlaceholder(childFrame);
       if (realFrame->GetType() == nsGkAtoms::letterFrame) {
         frame = realFrame;
       }
     }
 
-    auto DifferentBidiValues = [](nsIFrame* aFrame1, nsIFrame* aFrame2) {
-      nsStyleContext* sc1 = aFrame1->StyleContext();
+    auto DifferentBidiValues = [](nsStyleContext* aSC1, nsIFrame* aFrame2) {
       nsStyleContext* sc2 = aFrame2->StyleContext();
-      return GetBidiControl(sc1) != GetBidiControl(sc2) ||
-             GetBidiOverride(sc1) != GetBidiOverride(sc2);
+      return GetBidiControl(aSC1) != GetBidiControl(sc2) ||
+             GetBidiOverride(aSC1) != GetBidiOverride(sc2);
     };
 
+    nsStyleContext* sc = frame->StyleContext();
     nsIFrame* nextContinuation = frame->GetNextContinuation();
     nsIFrame* prevContinuation = frame->GetPrevContinuation();
     bool isLastFrame = !nextContinuation ||
-                       DifferentBidiValues(frame, nextContinuation);
+                       DifferentBidiValues(sc, nextContinuation);
     bool isFirstFrame = !prevContinuation ||
-                        DifferentBidiValues(frame, prevContinuation);
+                        DifferentBidiValues(sc, prevContinuation);
 
     char16_t controlChar = 0;
     char16_t overrideChar = 0;
     if (frame->IsFrameOfType(nsIFrame::eBidiInlineContainer)) {
       if (!(frame->GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
         nsContainerFrame* c = static_cast<nsContainerFrame*>(frame);
         MOZ_ASSERT(c == do_QueryFrame(frame),
                    "eBidiInlineContainer must be a nsContainerFrame subclass");
         c->DrainSelfOverflowList();
       }
 
-      controlChar = GetBidiControl(frame->StyleContext());
-      overrideChar = GetBidiOverride(frame->StyleContext());
+      controlChar = GetBidiControl(sc);
+      overrideChar = GetBidiOverride(sc);
 
       // Add dummy frame pointers representing bidi control codes before
       // the first frames of elements specifying override, isolation, or
       // plaintext.
       if (isFirstFrame) {
         if (controlChar != 0) {
           aBpd->PushBidiControl(controlChar);
         }