Skip to content
  • benjamin@webkit.org's avatar
    Do the DecimalNumber to String conversion on 8 bits · 8e69866a
    benjamin@webkit.org authored
    https://bugs.webkit.org/show_bug.cgi?id=93683
    
    Patch by Benjamin Poulain <bpoulain@apple.com> on 2012-08-11
    Reviewed by Andreas Kling.
    
    Source/WebCore: 
    
    Numbers converted to string for CSS are unlikely to ever be concatenated with a 16bits string.
    This patch change the conversion to be done to 8bits string in order to reduce memory allocations.
    
    * css/CSSPrimitiveValue.cpp:
    (WebCore::formatNumber):
    * inspector/InspectorValues.cpp:
    (WebCore::InspectorBasicValue::writeJSON):
    * platform/graphics/Color.cpp:
    (WebCore::Color::serialized): Instead of allocating a static WTF::String, we can simply append the
    string literal to the output vector.
    
    Source/WTF: 
    
    Modify DecimalNumber to do the conversion to string on LChar instead of UChar.
    
    * wtf/DecimalNumber.cpp:
    (WTF::DecimalNumber::toStringDecimal):
    (WTF::DecimalNumber::toStringExponential):
    * wtf/DecimalNumber.h:
    (DecimalNumber):
    * wtf/dtoa.h:
    * wtf/text/StringBuffer.h:
    (WTF::StringBuffer::operator[]): StringBuffer::operator[] was incorrectly typed to UChar, making
    the method impossible to instanciate with LChar.
    * wtf/text/WTFString.h:
    (String):
    (WTF::String::adopt): String::adopt() is modified to work with both LChar and UChar. StringImpl
    already support that.
    (WTF::appendNumber): Add support for any type that can instanciate the template.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@125357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    8e69866a