Title: [156334] trunk/Source/WebCore
Revision
156334
Author
[email protected]
Date
2013-09-24 09:20:20 -0700 (Tue, 24 Sep 2013)

Log Message

Cache continuation() in a local to avoid repeat hash lookups.
<https://webkit.org/b/121840>

Reviewed by Geoffrey Garen.

RenderBoxModelObject::continuation() does a hash lookup every time.
Cache the result in a local instead of calling it repeatedly.

* rendering/RenderBlock.h:
(WebCore::RenderBlock::isAnonymousBlockContinuation):

    Reorder to check bitfield before hash map.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::updateDragState):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::absoluteRects):
(WebCore::RenderInline::absoluteQuads):
(WebCore::RenderInline::clippedOverflowRectForRepaint):
(WebCore::RenderInline::updateDragState):
(WebCore::RenderInline::addFocusRingRects):

    Cache continuation() in locals where it's used more than once.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (156333 => 156334)


--- trunk/Source/WebCore/ChangeLog	2013-09-24 14:25:09 UTC (rev 156333)
+++ trunk/Source/WebCore/ChangeLog	2013-09-24 16:20:20 UTC (rev 156334)
@@ -1,3 +1,29 @@
+2013-09-24  Andreas Kling  <[email protected]>
+
+        Cache continuation() in a local to avoid repeat hash lookups.
+        <https://webkit.org/b/121840>
+
+        Reviewed by Geoffrey Garen.
+
+        RenderBoxModelObject::continuation() does a hash lookup every time.
+        Cache the result in a local instead of calling it repeatedly.
+
+        * rendering/RenderBlock.h:
+        (WebCore::RenderBlock::isAnonymousBlockContinuation):
+
+            Reorder to check bitfield before hash map.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::updateDragState):
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::absoluteRects):
+        (WebCore::RenderInline::absoluteQuads):
+        (WebCore::RenderInline::clippedOverflowRectForRepaint):
+        (WebCore::RenderInline::updateDragState):
+        (WebCore::RenderInline::addFocusRingRects):
+
+            Cache continuation() in locals where it's used more than once.
+
 2013-09-24  Allan Sandfeld Jensen  <[email protected]>
 
         [Qt] Crash when trying to download blob url

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (156333 => 156334)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-09-24 14:25:09 UTC (rev 156333)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-09-24 16:20:20 UTC (rev 156334)
@@ -6235,8 +6235,8 @@
 void RenderBlock::updateDragState(bool dragOn)
 {
     RenderBox::updateDragState(dragOn);
-    if (continuation())
-        continuation()->updateDragState(dragOn);
+    if (RenderBoxModelObject* continuation = this->continuation())
+        continuation->updateDragState(dragOn);
 }
 
 RenderStyle* RenderBlock::outlineStyleForRepaint() const

Modified: trunk/Source/WebCore/rendering/RenderBlock.h (156333 => 156334)


--- trunk/Source/WebCore/rendering/RenderBlock.h	2013-09-24 14:25:09 UTC (rev 156333)
+++ trunk/Source/WebCore/rendering/RenderBlock.h	2013-09-24 16:20:20 UTC (rev 156334)
@@ -273,7 +273,7 @@
     bool paintsContinuationOutline(RenderInline*);
 
     virtual RenderBoxModelObject* virtualContinuation() const OVERRIDE FINAL { return continuation(); }
-    bool isAnonymousBlockContinuation() const { return continuation() && isAnonymousBlock(); }
+    bool isAnonymousBlockContinuation() const { return isAnonymousBlock() && continuation(); }
     RenderInline* inlineElementContinuation() const;
     RenderBlock* blockElementContinuation() const;
 

Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (156333 => 156334)


--- trunk/Source/WebCore/rendering/RenderInline.cpp	2013-09-24 14:25:09 UTC (rev 156333)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp	2013-09-24 16:20:20 UTC (rev 156334)
@@ -651,12 +651,12 @@
     AbsoluteRectsGeneratorContext context(rects, accumulatedOffset);
     generateLineBoxRects(context);
 
-    if (continuation()) {
-        if (continuation()->isBox()) {
-            RenderBox* box = toRenderBox(continuation());
-            continuation()->absoluteRects(rects, toLayoutPoint(accumulatedOffset - containingBlock()->location() + box->locationOffset()));
+    if (RenderBoxModelObject* continuation = this->continuation()) {
+        if (continuation->isBox()) {
+            RenderBox* box = toRenderBox(continuation);
+            continuation->absoluteRects(rects, toLayoutPoint(accumulatedOffset - containingBlock()->location() + box->locationOffset()));
         } else
-            continuation()->absoluteRects(rects, toLayoutPoint(accumulatedOffset - containingBlock()->location()));
+            continuation->absoluteRects(rects, toLayoutPoint(accumulatedOffset - containingBlock()->location()));
     }
 }
 
@@ -688,8 +688,8 @@
     AbsoluteQuadsGeneratorContext context(this, quads);
     generateLineBoxRects(context);
 
-    if (continuation())
-        continuation()->absoluteQuads(quads, wasFixed);
+    if (RenderBoxModelObject* continuation = this->continuation())
+        continuation->absoluteQuads(quads, wasFixed);
 }
 
 LayoutUnit RenderInline::offsetLeft() const
@@ -1071,8 +1071,10 @@
                 repaintRect.unite(curr->rectWithOutlineForRepaint(repaintContainer, outlineSize));
         }
 
-        if (continuation() && !continuation()->isInline() && continuation()->parent())
-            repaintRect.unite(continuation()->rectWithOutlineForRepaint(repaintContainer, outlineSize));
+        if (RenderBoxModelObject* continuation = this->continuation()) {
+            if (!continuation->isInline() && continuation->parent())
+                repaintRect.unite(continuation->rectWithOutlineForRepaint(repaintContainer, outlineSize));
+        }
     }
 
     return repaintRect;
@@ -1254,8 +1256,8 @@
 void RenderInline::updateDragState(bool dragOn)
 {
     RenderBoxModelObject::updateDragState(dragOn);
-    if (continuation())
-        continuation()->updateDragState(dragOn);
+    if (RenderBoxModelObject* continuation = this->continuation())
+        continuation->updateDragState(dragOn);
 }
 
 void RenderInline::childBecameNonInline(RenderObject* child)
@@ -1430,11 +1432,11 @@
         }
     }
 
-    if (continuation()) {
-        if (continuation()->isInline())
-            continuation()->addFocusRingRects(rects, flooredLayoutPoint(additionalOffset + continuation()->containingBlock()->location() - containingBlock()->location()), paintContainer);
+    if (RenderBoxModelObject* continuation = this->continuation()) {
+        if (continuation->isInline())
+            continuation->addFocusRingRects(rects, flooredLayoutPoint(additionalOffset + continuation->containingBlock()->location() - containingBlock()->location()), paintContainer);
         else
-            continuation()->addFocusRingRects(rects, flooredLayoutPoint(additionalOffset + toRenderBox(continuation())->location() - containingBlock()->location()), paintContainer);
+            continuation->addFocusRingRects(rects, flooredLayoutPoint(additionalOffset + toRenderBox(continuation)->location() - containingBlock()->location()), paintContainer);
     }
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to