RenderInline: Skip caching the computed line height.
authorkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jan 2012 20:22:00 +0000 (20:22 +0000)
committerkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jan 2012 20:22:00 +0000 (20:22 +0000)
<http://webkit.org/b/76929>

Reviewed by David Hyatt.

Stop caching the computed line height on RenderInline and make retrieving it from
RenderStyle slightly cheaper, freeing up 4 bytes per RenderInline instance.
This appears to be mostly performance neutral, I don't get more than the occasional
sample hit when instrumenting heavier web pages.

This reduces memory consumption by 228 kB (both 32/64-bit) when viewing the full
HTML5 spec at <http://whatwg.org/c>.

* rendering/RenderInline.cpp:
(WebCore::RenderInline::RenderInline):
(WebCore::RenderInline::styleDidChange):
(WebCore::RenderInline::lineHeight):
* rendering/RenderInline.h:
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::computedLineHeight):

    Optimize computedLineHeight() to mitigate some of the damage of calling
    it more often.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@105771 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderInline.cpp
Source/WebCore/rendering/RenderInline.h
Source/WebCore/rendering/style/RenderStyle.h

index a6c623e..fedf75a 100644 (file)
@@ -1,3 +1,29 @@
+2012-01-24  Andreas Kling  <awesomekling@apple.com>
+
+        RenderInline: Skip caching the computed line height.
+        <http://webkit.org/b/76929>
+
+        Reviewed by David Hyatt.
+
+        Stop caching the computed line height on RenderInline and make retrieving it from
+        RenderStyle slightly cheaper, freeing up 4 bytes per RenderInline instance.
+        This appears to be mostly performance neutral, I don't get more than the occasional
+        sample hit when instrumenting heavier web pages.
+
+        This reduces memory consumption by 228 kB (both 32/64-bit) when viewing the full
+        HTML5 spec at <http://whatwg.org/c>.
+
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::RenderInline):
+        (WebCore::RenderInline::styleDidChange):
+        (WebCore::RenderInline::lineHeight):
+        * rendering/RenderInline.h:
+        * rendering/style/RenderStyle.h:
+        (WebCore::RenderStyle::computedLineHeight):
+
+            Optimize computedLineHeight() to mitigate some of the damage of calling
+            it more often.
+
 2012-01-24  Abhishek Arya  <inferno@chromium.org>
 
         Crash when rendering -webkit-column-span.
index 96b3925..12a9dfc 100644 (file)
@@ -47,7 +47,6 @@ namespace WebCore {
 
 RenderInline::RenderInline(Node* node)
     : RenderBoxModelObject(node)
-    , m_lineHeight(-1)
     , m_alwaysCreateLineBoxes(false)
 {
     setChildrenInline(true);
@@ -145,8 +144,6 @@ void RenderInline::styleDidChange(StyleDifference diff, const RenderStyle* oldSt
         currCont->setContinuation(nextCont);
     }
 
-    m_lineHeight = -1;
-
     if (!m_alwaysCreateLineBoxes) {
         bool alwaysCreateLineBoxes = hasSelfPaintingLayer() || hasBoxDecorations() || newStyle->hasPadding() || newStyle->hasMargin() || hasOutline();
         if (oldStyle && alwaysCreateLineBoxes) {
@@ -1269,11 +1266,8 @@ LayoutUnit RenderInline::lineHeight(bool firstLine, LineDirectionMode /*directio
         if (s != style())
             return s->computedLineHeight();
     }
-    
-    if (m_lineHeight == -1)
-        m_lineHeight = style()->computedLineHeight();
-    
-    return m_lineHeight;
+
+    return style()->computedLineHeight();
 }
 
 LayoutUnit RenderInline::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const
index 06ad965..557ce59 100644 (file)
@@ -168,7 +168,6 @@ private:
     RenderObjectChildList m_children;
     RenderLineBoxList m_lineBoxes;   // All of the line boxes created for this inline flow.  For example, <i>Hello<br>world.</i> will have two <i> line boxes.
 
-    mutable LayoutUnit m_lineHeight;
     bool m_alwaysCreateLineBoxes : 1;
 };
 
index 812bf4e..5f0559b 100644 (file)
@@ -615,7 +615,7 @@ public:
     Length lineHeight() const { return inherited->line_height; }
     int computedLineHeight() const
     {
-        Length lh = lineHeight();
+        const Length& lh = inherited->line_height;
 
         // Negative value means the line height is not set.  Use the font's built-in spacing.
         if (lh.isNegative())