Ignore:
Timestamp:
Aug 26, 2010, 5:38:54 PM (15 years ago)
Author:
[email protected]
Message:

Rubber Stamped by Oliver Hunt.

Partially revert r65959. The toString changes regressed the v8 tests,
but keep the toFixed/toExponential/toPrecision changes.

JavaScriptCore:

(JSC::UString::number):

  • wtf/DecimalNumber.h:
  • wtf/dtoa.cpp:

(WTF::append):
(WTF::doubleToStringInJavaScriptFormat):

  • wtf/dtoa.h:
  • wtf/text/WTFString.cpp:
  • wtf/text/WTFString.h:

WebCore:

  • html/HTMLTreeBuilder.cpp:

(WebCore::serializeForNumberType):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/text/WTFString.cpp

    r66142 r66159  
    2626#include <stdarg.h>
    2727#include <wtf/ASCIICType.h>
    28 #include <wtf/DecimalNumber.h>
     28#include <wtf/text/CString.h>
    2929#include <wtf/StringExtras.h>
    3030#include <wtf/Vector.h>
    31 #include <wtf/text/CString.h>
     31#include <wtf/dtoa.h>
    3232#include <wtf/unicode/UTF8.h>
    3333#include <wtf/unicode/Unicode.h>
     
    948948}
    949949
    950 static unsigned copyToString(const char* string, unsigned length, NumberToStringBuffer& buffer)
    951 {
    952     for (unsigned i = 0; i < length; ++i)
    953         buffer[i] = string[i];
    954     return length;
    955 }
    956 
    957 static NEVER_INLINE unsigned nanOrInfToString(double x, NumberToStringBuffer& buffer)
    958 {
    959     ASSERT(isnan(x) || isinf(x));
    960     if (isnan(x))
    961         return copyToString("NaN", 3, buffer);
    962     if (x < 0)
    963         return copyToString("-Infinity", 9, buffer);
    964     return copyToString("Infinity", 8, buffer);
    965 }
    966 
    967 // toString converts a number to a string without rounding. For values in the range
    968 // 1e-6 <= x < 1e+21 the result is formatted as a decimal, with values outside of
    969 // this range being formatted as an exponential.
    970 unsigned numberToString(double x, NumberToStringBuffer& buffer)
    971 {
    972     // Handle NaN and Infinity.
    973     if (UNLIKELY(isnan(x) || isinf(x)))
    974         return nanOrInfToString(x, buffer);
    975 
    976     // Convert to decimal, no rounding.
    977     DecimalNumber number(x);
    978 
    979     // Format as decimal or exponential, depending on the exponent.
    980     return number.exponent() >= -6 && number.exponent() < 21
    981         ? number.toStringDecimal(buffer)
    982         : number.toStringExponential(buffer);
    983 }
    984 
    985950} // namespace WTF
    986951
Note: See TracChangeset for help on using the changeset viewer.