Skip to content
Permalink
Browse files
Skip unnecessary null check in RenderText::textLength().
<https://webkit.org/b/122841>

Reviewed by Antti Koivisto.

RenderText will never have a null String in m_text, so textLength()
can grab at the StringImpl directly, avoiding a null check.


Canonical link: https://commits.webkit.org/140925@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@157456 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Andreas Kling committed Oct 15, 2013
1 parent 968ce27 commit cc190a6b59840525ec2e7e2eafc80ee9c886f698
Showing with 14 additions and 4 deletions.
  1. +10 −0 Source/WebCore/ChangeLog
  2. +3 −3 Source/WebCore/rendering/RenderText.cpp
  3. +1 −1 Source/WebCore/rendering/RenderText.h
@@ -1,3 +1,13 @@
2013-10-15 Andreas Kling <akling@apple.com>

Skip unnecessary null check in RenderText::textLength().
<https://webkit.org/b/122841>

Reviewed by Antti Koivisto.

RenderText will never have a null String in m_text, so textLength()
can grab at the StringImpl directly, avoiding a null check.

2013-10-15 Andreas Kling <akling@apple.com>

FontGenericFamilies should not be ref-counted.
@@ -159,7 +159,7 @@ RenderText::RenderText(Text& textNode, const String& text)
ASSERT(!m_text.isNull());
setIsText();
m_canUseSimpleFontCodePath = computeCanUseSimpleFontCodePath();
view().frameView().incrementVisuallyNonEmptyCharacterCount(m_text.length());
view().frameView().incrementVisuallyNonEmptyCharacterCount(textLength());
}

RenderText::RenderText(Document& document, const String& text)
@@ -182,7 +182,7 @@ RenderText::RenderText(Document& document, const String& text)
ASSERT(!m_text.isNull());
setIsText();
m_canUseSimpleFontCodePath = computeCanUseSimpleFontCodePath();
view().frameView().incrementVisuallyNonEmptyCharacterCount(m_text.length());
view().frameView().incrementVisuallyNonEmptyCharacterCount(textLength());
}

#ifndef NDEBUG
@@ -950,7 +950,7 @@ void RenderText::setTextInternal(const String& text)

void RenderText::secureText(UChar mask)
{
if (!m_text.length())
if (!textLength())
return;

int lastTypedCharacterOffsetToReveal = -1;
@@ -77,7 +77,7 @@ class RenderText : public RenderObject {
const UChar* characters() const { return m_text.characters(); }
UChar characterAt(unsigned i) const { return is8Bit() ? characters8()[i] : characters16()[i]; }
UChar operator[](unsigned i) const { return characterAt(i); }
unsigned textLength() const { return m_text.length(); } // non virtual implementation of length()
unsigned textLength() const { return m_text.impl()->length(); } // non virtual implementation of length()
void positionLineBox(InlineBox*);

virtual float width(unsigned from, unsigned len, const Font&, float xPos, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;

0 comments on commit cc190a6

Please sign in to comment.