Changeset 211394 in webkit


Ignore:
Timestamp:
Jan 30, 2017 4:17:04 PM (7 years ago)
Author:
Alan Bujtas
Message:

Simple line layout: Small tweaks to improve performance.
https://bugs.webkit.org/show_bug.cgi?id=167611
<rdar://problem/30274294>

Reviewed by Simon Fraser.

PerformanceTests:

  • Layout/simple-line-layout-non-repeating-text.html: Added.

Source/WebCore:

This is ~10% progression on the attached test case (paragraphs with non-redundant content).
median: 102.08 runs/s -> median: 114.25 runs/s

  • rendering/SimpleLineLayout.cpp:

(WebCore::SimpleLineLayout::LineState::appendFragmentAndCreateRunIfNeeded):

  • rendering/SimpleLineLayoutFlowContents.cpp:

(WebCore::SimpleLineLayout::initializeSegments):
(WebCore::SimpleLineLayout::FlowContents::FlowContents):

  • rendering/SimpleLineLayoutFlowContents.h:
  • rendering/SimpleLineLayoutTextFragmentIterator.cpp:

(WebCore::SimpleLineLayout::TextFragmentIterator::nextNonWhitespacePosition):
(WebCore::SimpleLineLayout::TextFragmentIterator::skipToNextPosition):

  • rendering/SimpleLineLayoutTextFragmentIterator.h:
Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/PerformanceTests/ChangeLog

    r210757 r211394  
     12017-01-30  Zalan Bujtas  <zalan@apple.com>
     2
     3        Simple line layout: Small tweaks to improve performance.
     4        https://bugs.webkit.org/show_bug.cgi?id=167611
     5        <rdar://problem/30274294>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * Layout/simple-line-layout-non-repeating-text.html: Added.
     10
    1112017-01-13  Said Abou-Hallawa  <sabouhallawa@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r211393 r211394  
     12017-01-30  Zalan Bujtas  <zalan@apple.com>
     2
     3        Simple line layout: Small tweaks to improve performance.
     4        https://bugs.webkit.org/show_bug.cgi?id=167611
     5        <rdar://problem/30274294>
     6
     7        Reviewed by Simon Fraser.
     8
     9        This is ~10% progression on the attached test case (paragraphs with non-redundant content).
     10        median: 102.08 runs/s -> median: 114.25 runs/s
     11
     12        * rendering/SimpleLineLayout.cpp:
     13        (WebCore::SimpleLineLayout::LineState::appendFragmentAndCreateRunIfNeeded):
     14        * rendering/SimpleLineLayoutFlowContents.cpp:
     15        (WebCore::SimpleLineLayout::initializeSegments):
     16        (WebCore::SimpleLineLayout::FlowContents::FlowContents):
     17        * rendering/SimpleLineLayoutFlowContents.h:
     18        * rendering/SimpleLineLayoutTextFragmentIterator.cpp:
     19        (WebCore::SimpleLineLayout::TextFragmentIterator::nextNonWhitespacePosition):
     20        (WebCore::SimpleLineLayout::TextFragmentIterator::skipToNextPosition):
     21        * rendering/SimpleLineLayoutTextFragmentIterator.h:
     22
    1232017-01-30  Chris Dumez  <cdumez@apple.com>
    224
  • trunk/Source/WebCore/rendering/SimpleLineLayout.cpp

    r211292 r211394  
    461461            runs.append(Run(fragment.start(), endPosition, m_runsWidth, m_runsWidth + fragment.width(), false, fragment.hasHyphen()));
    462462        else {
    463             const auto& lastFragment = m_fragments.last();
     463            auto& lastFragment = m_fragments.last();
    464464            // Advance last completed fragment when the previous fragment is all set (including multiple parts across renderers)
    465465            if ((lastFragment.type() != fragment.type()) || !lastFragment.overlapsToNextRenderer())
     
    562562    // First character of the first fragment might be forced on to the current line even if it does not fit.
    563563    bool m_firstCharacterFits { false };
    564     Vector<TextFragmentIterator::TextFragment> m_fragments;
     564    // FIXME: We don't actually need this for all the simple cases. Try to remove/make it optional.
     565    Vector<TextFragmentIterator::TextFragment, 30> m_fragments;
    565566};
    566567
  • trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.cpp

    r185531 r211394  
    4444    segments.reserveCapacity(numberOfChildren);
    4545    unsigned startPosition = 0;
    46     for (const auto& child : childrenOfType<RenderObject>(flow)) {
     46    for (auto& child : childrenOfType<RenderObject>(flow)) {
    4747        if (is<RenderText>(child)) {
    48             const auto& textChild = downcast<RenderText>(child);
     48            auto& textChild = downcast<RenderText>(child);
    4949            unsigned textLength = textChild.text()->length();
    5050            segments.append(FlowContents::Segment { startPosition, startPosition + textLength, textChild.text(), textChild });
     
    6363FlowContents::FlowContents(const RenderBlockFlow& flow)
    6464    : m_segments(initializeSegments(flow))
    65     , m_lastSegmentIndex(0)
    6665{
    6766}
  • trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h

    r211108 r211394  
    4646        unsigned start;
    4747        unsigned end;
    48         String text;
     48        StringView text;
    4949        const RenderObject& renderer;
    5050    };
     
    5858    unsigned segmentIndexForRunSlow(unsigned start, unsigned end) const;
    5959    const Vector<Segment, 8> m_segments;
    60     mutable unsigned m_lastSegmentIndex;
     60    mutable unsigned m_lastSegmentIndex { 0 };
    6161};
    6262
  • trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp

    r211228 r211394  
    154154}
    155155
    156 template <typename CharacterType>
    157156unsigned TextFragmentIterator::nextNonWhitespacePosition(const FlowContents::Segment& segment, unsigned startPosition)
    158157{
    159158    ASSERT(startPosition < segment.end);
    160     const auto* text = segment.text.characters<CharacterType>();
    161159    unsigned position = startPosition;
    162160    for (; position < segment.end; ++position) {
    163         auto character = text[segment.toSegmentPosition(position)];
     161        auto character = segment.text[segment.toSegmentPosition(position)];
    164162        bool isWhitespace = character == ' ' || character == '\t' || (!m_style.preserveNewline && character == '\n');
    165163        if (!isWhitespace)
     
    214212    // Collapsed whitespace has constant width. Do not measure it.
    215213    if (positionType == NonWhitespace)
    216         nextPosition = m_currentSegment->text.is8Bit() ? nextNonWhitespacePosition<LChar>(*m_currentSegment, currentPosition) : nextNonWhitespacePosition<UChar>(*m_currentSegment, currentPosition);
     214        nextPosition = nextNonWhitespacePosition(*m_currentSegment, currentPosition);
    217215    else if (positionType == Breakable) {
    218216        nextPosition = nextBreakablePosition(*m_currentSegment, currentPosition);
  • trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h

    r211228 r211394  
    134134    bool isHardLineBreak(const FlowContents::Iterator& segment) const;
    135135    unsigned nextBreakablePosition(const FlowContents::Segment&, unsigned startPosition);
    136     template <typename CharacterType> unsigned nextNonWhitespacePosition(const FlowContents::Segment&, unsigned startPosition);
     136    unsigned nextNonWhitespacePosition(const FlowContents::Segment&, unsigned startPosition);
    137137    float runWidth(const FlowContents::Segment&, unsigned startPosition, unsigned endPosition, float xPosition) const;
    138138
Note: See TracChangeset for help on using the changeset viewer.