Changeset 220383 in webkit


Ignore:
Timestamp:
Aug 7, 2017 7:52:10 PM (7 years ago)
Author:
Simon Fraser
Message:

RenderStyle:diff() was inadvertently doing deep compares of StyleRareNonInheritedData etc
https://bugs.webkit.org/show_bug.cgi?id=175304

Reviewed by Tim Horton.

r210758 changed DataRef::get() from returning a pointer to a reference. This caused all the places
in RenderStyle::diff() and related functions, where we intended to do a quick pointer comparison,
to doing deep compares via operator!=. This made the code slightly slower.

Fix by exposing ptr() on DataRef and using it wherever we wish to do pointer comparison.

  • rendering/style/DataRef.h:

(WebCore::DataRef::ptr const):

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::inheritedDataShared const):
(WebCore::RenderStyle::changeAffectsVisualOverflow const):
(WebCore::RenderStyle::changeRequiresLayout const):
(WebCore::RenderStyle::changeRequiresRecompositeLayer const):
(WebCore::RenderStyle::listStyleImage const): Expand the function onto multiple lines.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r220382 r220383  
     12017-08-07  Simon Fraser  <simon.fraser@apple.com>
     2
     3        RenderStyle:diff() was inadvertently doing deep compares of StyleRareNonInheritedData etc
     4        https://bugs.webkit.org/show_bug.cgi?id=175304
     5
     6        Reviewed by Tim Horton.
     7
     8        r210758 changed DataRef::get() from returning a pointer to a reference. This caused all the places
     9        in RenderStyle::diff() and related functions, where we intended to do a quick pointer comparison,
     10        to doing deep compares via operator!=. This made the code slightly slower.
     11
     12        Fix by exposing ptr() on DataRef and using it wherever we wish to do pointer comparison.
     13
     14        * rendering/style/DataRef.h:
     15        (WebCore::DataRef::ptr const):
     16        * rendering/style/RenderStyle.cpp:
     17        (WebCore::RenderStyle::inheritedDataShared const):
     18        (WebCore::RenderStyle::changeAffectsVisualOverflow const):
     19        (WebCore::RenderStyle::changeRequiresLayout const):
     20        (WebCore::RenderStyle::changeRequiresRecompositeLayer const):
     21        (WebCore::RenderStyle::listStyleImage const): Expand the function onto multiple lines.
     22
    1232017-08-07  Simon Fraser  <simon.fraser@apple.com>
    224
  • trunk/Source/WebCore/rendering/style/DataRef.h

    r210758 r220383  
    5656    }
    5757
     58    const T* ptr() const
     59    {
     60        return m_data.ptr();
     61    }
     62
    5863    const T& get() const
    5964    {
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r219544 r220383  
    453453    // This is a fast check that only looks if the data structures are shared.
    454454    return m_inheritedFlags == other->m_inheritedFlags
    455         && m_inheritedData.get() == other->m_inheritedData.get()
    456         && m_svgStyle.get() == other->m_svgStyle.get()
    457         && m_rareInheritedData.get() == other->m_rareInheritedData.get();
     455        && m_inheritedData.ptr() == other->m_inheritedData.ptr()
     456        && m_svgStyle.ptr() == other->m_svgStyle.ptr()
     457        && m_rareInheritedData.ptr() == other->m_rareInheritedData.ptr();
    458458}
    459459
     
    487487inline bool RenderStyle::changeAffectsVisualOverflow(const RenderStyle& other) const
    488488{
    489     if (m_rareNonInheritedData.get() != other.m_rareNonInheritedData.get()
     489    if (m_rareNonInheritedData.ptr() != other.m_rareNonInheritedData.ptr()
    490490        && !arePointingToEqualData(m_rareNonInheritedData->boxShadow, other.m_rareNonInheritedData->boxShadow))
    491491        return true;
    492492
    493     if (m_rareInheritedData.get() != other.m_rareInheritedData.get()
     493    if (m_rareInheritedData.ptr() != other.m_rareInheritedData.ptr()
    494494        && !arePointingToEqualData(m_rareInheritedData->textShadow, other.m_rareInheritedData->textShadow))
    495495        return true;
     
    537537        return true;
    538538
    539     if (m_rareNonInheritedData.get() != other.m_rareNonInheritedData.get()) {
     539    if (m_rareNonInheritedData.ptr() != other.m_rareNonInheritedData.ptr()) {
    540540        if (m_rareNonInheritedData->appearance != other.m_rareNonInheritedData->appearance
    541541            || m_rareNonInheritedData->marginBeforeCollapse != other.m_rareNonInheritedData->marginBeforeCollapse
     
    598598    }
    599599
    600     if (m_rareInheritedData.get() != other.m_rareInheritedData.get()) {
     600    if (m_rareInheritedData.ptr() != other.m_rareInheritedData.ptr()) {
    601601        if (m_rareInheritedData->indent != other.m_rareInheritedData->indent
    602602#if ENABLE(CSS3_TEXT)
     
    911911bool RenderStyle::changeRequiresRecompositeLayer(const RenderStyle& other, unsigned&) const
    912912{
    913     if (m_rareNonInheritedData.get() != other.m_rareNonInheritedData.get()) {
     913    if (m_rareNonInheritedData.ptr() != other.m_rareNonInheritedData.ptr()) {
    914914        if (m_rareNonInheritedData->transformStyle3D != other.m_rareNonInheritedData->transformStyle3D
    915915            || m_rareNonInheritedData->backfaceVisibility != other.m_rareNonInheritedData->backfaceVisibility
     
    11971197}
    11981198
    1199 StyleImage* RenderStyle::listStyleImage() const { return m_rareInheritedData->listStyleImage.get(); }
     1199StyleImage* RenderStyle::listStyleImage() const
     1200{
     1201    return m_rareInheritedData->listStyleImage.get();
     1202}
    12001203
    12011204void RenderStyle::setListStyleImage(RefPtr<StyleImage>&& v)
Note: See TracChangeset for help on using the changeset viewer.