Changeset 142398 in webkit


Ignore:
Timestamp:
Feb 10, 2013 5:44:02 AM (11 years ago)
Author:
akling@apple.com
Message:

RenderText: Access characters through m_text instead of caching data pointers separately.
<http://webkit.org/b/109357>

Reviewed by Antti Koivisto.

Go through RenderText::m_text.impl() instead of caching the character data pointer.
RenderText should never have a null String in m_text so it's safe to access impl() directly.
We have assertions for this since before.

Removing this pointer shrinks RenderText by 8 bytes, allowing it to fit into a snugger size class.
749 KB progression on Membuster3.

  • rendering/RenderText.cpp:

(SameSizeAsRenderText):
(WebCore::RenderText::RenderText):
(WebCore::RenderText::setTextInternal):

  • rendering/RenderText.h:

(WebCore::RenderText::is8Bit):
(WebCore::RenderText::characters8):
(WebCore::RenderText::characters16):
(WebCore::RenderText::characterAt):
(WebCore::RenderText::operator[]):
(RenderText):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r142395 r142398  
     12013-02-10  Andreas Kling  <akling@apple.com>
     2
     3        RenderText: Access characters through m_text instead of caching data pointers separately.
     4        <http://webkit.org/b/109357>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Go through RenderText::m_text.impl() instead of caching the character data pointer.
     9        RenderText should never have a null String in m_text so it's safe to access impl() directly.
     10        We have assertions for this since before.
     11
     12        Removing this pointer shrinks RenderText by 8 bytes, allowing it to fit into a snugger size class.
     13        749 KB progression on Membuster3.
     14
     15        * rendering/RenderText.cpp:
     16        (SameSizeAsRenderText):
     17        (WebCore::RenderText::RenderText):
     18        (WebCore::RenderText::setTextInternal):
     19        * rendering/RenderText.h:
     20        (WebCore::RenderText::is8Bit):
     21        (WebCore::RenderText::characters8):
     22        (WebCore::RenderText::characters16):
     23        (WebCore::RenderText::characterAt):
     24        (WebCore::RenderText::operator[]):
     25        (RenderText):
     26
    1272013-02-10  Jae Hyun Park  <jae.park08@gmail.com>
    228
  • trunk/Source/WebCore/rendering/RenderText.cpp

    r141570 r142398  
    6060    float widths[4];
    6161    String text;
    62     void* pointers[3];
     62    void* pointers[2];
    6363};
    6464
     
    157157        setDocumentForAnonymous(static_cast<Document*>(node));
    158158
    159     m_is8Bit = m_text.is8Bit();
    160     if (is8Bit())
    161         m_data.characters8 = m_text.characters8();
    162     else
    163         m_data.characters16 = m_text.characters16();
    164159    m_isAllASCII = m_text.containsOnlyASCII();
    165160    m_canUseSimpleFontCodePath = computeCanUseSimpleFontCodePath();
     
    14281423    ASSERT(!isBR() || (textLength() == 1 && m_text[0] == '\n'));
    14291424
    1430     m_is8Bit = m_text.is8Bit();
    1431     if (is8Bit())
    1432         m_data.characters8 = m_text.characters8();
    1433     else
    1434         m_data.characters16 = m_text.characters16();
    14351425    m_isAllASCII = m_text.containsOnlyASCII();
    14361426    m_canUseSimpleFontCodePath = computeCanUseSimpleFontCodePath();
  • trunk/Source/WebCore/rendering/RenderText.h

    r140693 r142398  
    7373    virtual VisiblePosition positionForPoint(const LayoutPoint&);
    7474
    75     bool is8Bit() const { return m_is8Bit; }
    76     const LChar* characters8() const { ASSERT(m_is8Bit); return m_data.characters8; }
    77     const UChar* characters16() const { ASSERT(!m_is8Bit); return m_data.characters16; }
     75    bool is8Bit() const { return m_text.is8Bit(); }
     76    const LChar* characters8() const { return m_text.impl()->characters8(); }
     77    const UChar* characters16() const { return m_text.impl()->characters16(); }
    7878    const UChar* characters() const { return m_text.characters(); }
    79     UChar characterAt(unsigned i) const { return m_is8Bit ? characters8()[i] : characters16()[i]; }
     79    UChar characterAt(unsigned i) const { return is8Bit() ? characters8()[i] : characters16()[i]; }
    8080    UChar operator[](unsigned i) const { return characterAt(i); }
    8181    unsigned textLength() const { return m_text.length(); } // non virtual implementation of length()
     
    192192                           // or removed).
    193193    bool m_containsReversedText : 1;
    194     bool m_is8Bit : 1;
    195194    bool m_isAllASCII : 1;
    196195    bool m_canUseSimpleFontCodePath : 1;
     
    204203
    205204    String m_text;
    206     union {
    207         const LChar* characters8;
    208         const UChar* characters16;
    209     } m_data;
    210205
    211206    InlineTextBox* m_firstTextBox;
Note: See TracChangeset for help on using the changeset viewer.