Changeset 62680 in webkit


Ignore:
Timestamp:
Jul 7, 2010 10:15:17 AM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-07-07 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

Grease the TreeBuilder's lightning
https://bugs.webkit.org/show_bug.cgi?id=41756

Brings the new TreeBuilder from 7s to 3s on the parser benchmark.
This makes performance comparable to the old parser.

We have not begun to fight! There is so much fat left on these bones.

  • html/HTMLFormattingElementList.cpp: (WebCore::HTMLFormattingElementList::find): (WebCore::HTMLFormattingElementList::bookmarkFor): (WebCore::HTMLFormattingElementList::insertAt): (WebCore::HTMLFormattingElementList::remove):
  • html/HTMLFormattingElementList.h: (WebCore::HTMLFormattingElementList::findIndex):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r62678 r62680  
     12010-07-07  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Grease the TreeBuilder's lightning
     6        https://bugs.webkit.org/show_bug.cgi?id=41756
     7
     8        Brings the new TreeBuilder from 7s to 3s on the parser benchmark.
     9        This makes performance comparable to the old parser.
     10
     11        We have not begun to fight!  There is so much fat left on these bones.
     12
     13        * html/HTMLFormattingElementList.cpp:
     14        (WebCore::HTMLFormattingElementList::find):
     15        (WebCore::HTMLFormattingElementList::bookmarkFor):
     16        (WebCore::HTMLFormattingElementList::insertAt):
     17        (WebCore::HTMLFormattingElementList::remove):
     18        * html/HTMLFormattingElementList.h:
     19        (WebCore::HTMLFormattingElementList::findIndex):
     20
    1212010-07-07  Eric Seidel  <eric@webkit.org>
    222
  • trunk/WebCore/html/HTMLFormattingElementList.cpp

    r62678 r62680  
    5959HTMLFormattingElementList::Entry* HTMLFormattingElementList::find(Element* element)
    6060{
    61     size_t index = m_entries.find(element);
     61    size_t index = findIndex(element);
    6262    if (index != notFound) {
    6363        // This is somewhat of a hack, and is why this method can't be const.
     
    6969HTMLFormattingElementList::Bookmark HTMLFormattingElementList::bookmarkFor(Element* element)
    7070{
    71     size_t index = m_entries.find(element);
     71    size_t index = findIndex(element);
    7272    ASSERT(index != notFound);
    7373    Element* elementBefore = (index > 1) ? m_entries[index - 1].element() : 0;
     
    8080    size_t beforeIndex = notFound;
    8181    if (bookmark.elementBefore()) {
    82         beforeIndex = m_entries.find(bookmark.elementBefore());
     82        beforeIndex = findIndex(bookmark.elementBefore());
    8383        ASSERT(beforeIndex != notFound);
    8484    }
    8585    size_t afterIndex = notFound;
    8686    if (bookmark.elementAfter()) {
    87         afterIndex = m_entries.find(bookmark.elementAfter());
     87        afterIndex = findIndex(bookmark.elementAfter());
    8888        ASSERT(afterIndex != notFound);
    8989    }
     
    110110void HTMLFormattingElementList::remove(Element* element)
    111111{
    112     size_t index = m_entries.find(element);
     112    size_t index = findIndex(element);
    113113    if (index != notFound)
    114114        m_entries.remove(index);
  • trunk/WebCore/html/HTMLFormattingElementList.h

    r62678 r62680  
    125125
    126126private:
     127    size_t findIndex(Element* element) const
     128    {
     129        // A reverse find is more efficient than Vector<T>::find
     130        for (size_t i = 1; i <= m_entries.size(); ++i) {
     131            size_t index = m_entries.size() - i;
     132            if (m_entries[index].element() == element)
     133                return index;
     134        }
     135        return notFound;
     136    }
    127137    Vector<Entry> m_entries;
    128138};
Note: See TracChangeset for help on using the changeset viewer.