Commit 843df6f3 authored by weinig@apple.com's avatar weinig@apple.com

JavaScriptCore:

2008-04-16  Sam Weinig  <sam@webkit.org>

        Reviewed by Darin Adler.

        - Remove kjs_ prefix from strtod, dtoa, and freedtoa and put it
          in the KJS namespace.
        - Make strtod, dtoa, and freedtoa c++ functions instead of extern "C".
        - Remove mode switching from dtoa.  ~2% improvement on test 26. 
        - Removes all unnecessary #defines from dtoa code.

        * JavaScriptCore.exp:
        * kjs/dtoa.cpp:
        (KJS::ulp):
        (KJS::b2d):
        (KJS::d2b):
        (KJS::ratio):
        (KJS::):
        (KJS::strtod):
        (KJS::freedtoa):
        (KJS::dtoa):
        * kjs/dtoa.h:
        * kjs/function.cpp:
        (KJS::parseInt):
        * kjs/lexer.cpp:
        (KJS::Lexer::lex):
        * kjs/number_object.cpp:
        (KJS::integer_part_noexp):
        (KJS::numberProtoFuncToExponential):
        * kjs/ustring.cpp:
        (KJS::UString::from):
        (KJS::UString::toDouble):

WebCore:

2008-04-16  Sam Weinig  <sam@webkit.org>

        Reviewed by Darin Adler.

        Rename kjs_strtod to KJS::strtod.

        * platform/text/String.cpp:
        (WebCore::charactersToDouble):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31948 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a2eb10ab
2008-04-16 Sam Weinig <sam@webkit.org>
Reviewed by Darin Adler.
- Remove kjs_ prefix from strtod, dtoa, and freedtoa and put it
in the KJS namespace.
- Make strtod, dtoa, and freedtoa c++ functions instead of extern "C".
- Remove mode switching from dtoa. ~2% improvement on test 26.
- Removes all unnecessary #defines from dtoa code.
* JavaScriptCore.exp:
* kjs/dtoa.cpp:
(KJS::ulp):
(KJS::b2d):
(KJS::d2b):
(KJS::ratio):
(KJS::):
(KJS::strtod):
(KJS::freedtoa):
(KJS::dtoa):
* kjs/dtoa.h:
* kjs/function.cpp:
(KJS::parseInt):
* kjs/lexer.cpp:
(KJS::Lexer::lex):
* kjs/number_object.cpp:
(KJS::integer_part_noexp):
(KJS::numberProtoFuncToExponential):
* kjs/ustring.cpp:
(KJS::UString::from):
(KJS::UString::toDouble):
2008-04-16 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Darin.
......
......@@ -149,6 +149,7 @@ __ZN3KJS6JSLock6unlockEv
__ZN3KJS6JSLock9lockCountEv
__ZN3KJS6Parser5parseEiPKtjPiS3_PNS_7UStringE
__ZN3KJS6parserEv
__ZN3KJS6strtodEPKcPPc
__ZN3KJS7CStringD1Ev
__ZN3KJS7CStringaSERKS0_
__ZN3KJS7UString3Rep11computeHashEPKti
......@@ -291,4 +292,3 @@ __ZTVN3KJS8JSObjectE
_jscore_collector_introspection
_jscore_fastmalloc_introspection
_kJSClassDefinitionEmpty
_kjs_strtod
This diff is collapsed.
/*
* Copyright (C) 2003 Apple Computer, Inc.
* Copyright (C) 2003, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -26,12 +26,13 @@ namespace WTF {
}
namespace KJS {
extern WTF::Mutex* s_dtoaP5Mutex;
}
extern "C" double kjs_strtod(const char* s00, char** se);
extern "C" char* kjs_dtoa(double d, int mode, int ndigits,
int* decpt, int* sign, char** rve);
extern "C" void kjs_freedtoa(char* s);
double strtod(const char* s00, char** se);
char* dtoa(double d, int ndigits, int* decpt, int* sign, char** rve);
void freedtoa(char* s);
} // namespace KJS
#endif /* KJS_dtoa_h */
......@@ -676,7 +676,7 @@ static double parseInt(const UString& s, int radix)
if (number >= mantissaOverflowLowerBound) {
if (radix == 10)
number = kjs_strtod(s.substr(firstDigitPosition, p - firstDigitPosition).ascii(), 0);
number = strtod(s.substr(firstDigitPosition, p - firstDigitPosition).ascii(), 0);
else if (radix == 2 || radix == 4 || radix == 8 || radix == 16 || radix == 32)
number = parseIntOverflow(s.substr(firstDigitPosition, p - firstDigitPosition).ascii(), p - firstDigitPosition, radix);
}
......
......@@ -479,7 +479,7 @@ int Lexer::lex(void* p1, void* p2)
double dval = 0;
if (state == Number) {
dval = kjs_strtod(m_buffer8.data(), 0L);
dval = strtod(m_buffer8.data(), 0L);
} else if (state == Hex) { // scan hex numbers
const char* p = m_buffer8.data() + 2;
while (char c = *p++) {
......
......@@ -75,7 +75,7 @@ static UString integer_part_noexp(double d)
{
int decimalPoint;
int sign;
char* result = kjs_dtoa(d, 0, 0, &decimalPoint, &sign, NULL);
char* result = dtoa(d, 0, &decimalPoint, &sign, NULL);
bool resultIsInfOrNan = (decimalPoint == 9999);
size_t length = strlen(result);
......@@ -97,7 +97,7 @@ static UString integer_part_noexp(double d)
str += UString(buf.data());
}
kjs_freedtoa(result);
freedtoa(result);
return str;
}
......@@ -353,7 +353,7 @@ JSValue* numberProtoFuncToExponential(ExecState* exec, JSObject* thisObj, const
int decimalPoint;
int sign;
char* result = kjs_dtoa(x, 0, 0, &decimalPoint, &sign, NULL);
char* result = dtoa(x, 0, &decimalPoint, &sign, NULL);
size_t resultLength = strlen(result);
decimalPoint += decimalAdjust;
......@@ -376,7 +376,7 @@ JSValue* numberProtoFuncToExponential(ExecState* exec, JSObject* thisObj, const
}
ASSERT(i <= 80);
kjs_freedtoa(result);
freedtoa(result);
return jsString(buf);
}
......
......@@ -616,7 +616,7 @@ UString UString::from(double d)
int decimalPoint;
int sign;
char *result = kjs_dtoa(d, 0, 0, &decimalPoint, &sign, NULL);
char *result = dtoa(d, 0, &decimalPoint, &sign, NULL);
int length = static_cast<int>(strlen(result));
int i = 0;
......@@ -669,9 +669,9 @@ UString UString::from(double d)
buf[i++] = static_cast<char>('0' + exponential % 10);
buf[i++] = '\0';
}
kjs_freedtoa(result);
freedtoa(result);
return UString(buf);
}
......@@ -991,7 +991,7 @@ double UString::toDouble(bool tolerateTrailingJunk, bool tolerateEmptyString) co
} else {
// regular number ?
char *end;
d = kjs_strtod(c, &end);
d = strtod(c, &end);
if ((d != 0.0 || end != c) && d != Inf && d != -Inf) {
c = end;
} else {
......
2008-04-16 Sam Weinig <sam@webkit.org>
Reviewed by Darin Adler.
Rename kjs_strtod to KJS::strtod.
* platform/text/String.cpp:
(WebCore::charactersToDouble):
2008-04-16 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Adam.
......@@ -778,7 +778,7 @@ double charactersToDouble(const UChar* data, size_t length, bool* ok)
bytes[i] = data[i] < 0x7F ? data[i] : '?';
bytes[length] = '\0';
char* end;
double val = kjs_strtod(bytes.data(), &end);
double val = KJS::strtod(bytes.data(), &end);
if (ok)
*ok = (end == 0 || *end == '\0');
return val;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment