Changeset 125990 in webkit


Ignore:
Timestamp:
Aug 19, 2012 8:39:59 PM (12 years ago)
Author:
benjamin@webkit.org
Message:

Remove the static Strings used for outputting values of CSS_ATTR, CSS_COUNTER, CSS_RECT
https://bugs.webkit.org/show_bug.cgi?id=94420

Reviewed by Kentaro Hara.

Use the new StringBuilder::appendLiteral() instead of keeping some WTF::String in
memory.

The patch reduces memory usage.
It also reduces the binary size (-1672 bytes on x86_64).
I did not measure any difference in performance.

  • css/CSSPrimitiveValue.cpp:

(WebCore::CSSPrimitiveValue::customCssText):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r125989 r125990  
     12012-08-19  Benjamin Poulain  <benjamin@webkit.org>
     2
     3        Remove the static Strings used for outputting values of CSS_ATTR, CSS_COUNTER, CSS_RECT
     4        https://bugs.webkit.org/show_bug.cgi?id=94420
     5
     6        Reviewed by Kentaro Hara.
     7
     8        Use the new StringBuilder::appendLiteral() instead of keeping some WTF::String in
     9        memory.
     10
     11        The patch reduces memory usage.
     12        It also reduces the binary size (-1672 bytes on x86_64).
     13        I did not measure any difference in performance.
     14
     15        * css/CSSPrimitiveValue.cpp:
     16        (WebCore::CSSPrimitiveValue::customCssText):
     17
    1182012-08-19  Rik Cabanier  <cabanier@adobe.com>
    219
  • trunk/Source/WebCore/css/CSSPrimitiveValue.cpp

    r125934 r125990  
    938938            break;
    939939        case CSS_ATTR: {
    940             DEFINE_STATIC_LOCAL(const String, attrParen, ("attr("));
    941 
    942940            StringBuilder result;
    943941            result.reserveCapacity(6 + m_value.string->length());
    944 
    945             result.append(attrParen);
     942            result.appendLiteral("attr(");
    946943            result.append(m_value.string);
    947944            result.append(')');
     
    956953            break;
    957954        case CSS_COUNTER: {
    958             DEFINE_STATIC_LOCAL(const String, counterParen, ("counter("));
    959             DEFINE_STATIC_LOCAL(const String, countersParen, ("counters("));
    960             DEFINE_STATIC_LOCAL(const String, commaSpace, (", "));
    961 
    962955            StringBuilder result;
    963956            String separator = m_value.counter->separator();
    964             result.append(separator.isEmpty() ? counterParen : countersParen);
     957            if (separator.isEmpty())
     958                result.appendLiteral("counter(");
     959            else
     960                result.appendLiteral("counters(");
    965961
    966962            result.append(m_value.counter->identifier());
    967963            if (!separator.isEmpty()) {
    968                 result.append(commaSpace);
     964                result.appendLiteral(", ");
    969965                result.append(quoteCSSStringIfNeeded(separator));
    970966            }
    971967            String listStyle = m_value.counter->listStyle();
    972968            if (!listStyle.isEmpty()) {
    973                 result.append(commaSpace);
     969                result.appendLiteral(", ");
    974970                result.append(listStyle);
    975971            }
     
    980976        }
    981977        case CSS_RECT: {
    982             DEFINE_STATIC_LOCAL(const String, rectParen, ("rect("));
    983 
    984978            Rect* rectVal = getRectValue();
    985             StringBuilder result;
    986             result.reserveCapacity(32);
    987             result.append(rectParen);
    988 
    989             result.append(rectVal->top()->cssText());
    990             result.append(' ');
    991 
    992             result.append(rectVal->right()->cssText());
    993             result.append(' ');
    994 
    995             result.append(rectVal->bottom()->cssText());
    996             result.append(' ');
    997 
    998             result.append(rectVal->left()->cssText());
    999             result.append(')');
    1000 
    1001             text = result.toString();
     979            text = "rect(" + rectVal->top()->cssText() + ' ' + rectVal->right()->cssText() + ' ' + rectVal->bottom()->cssText() + ' ' + rectVal->left()->cssText() + ')';
    1002980            break;
    1003981        }
Note: See TracChangeset for help on using the changeset viewer.