Commit 451d435e authored by darin's avatar darin

- a fix that gives another 1.5% on the iBench JavaScript test

        * kjs/ustring.cpp: (UString::from): Stop using sprintf to format integers.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2754 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 66092a36
2002-11-19 Darin Adler <darin@apple.com>
- a fix that gives another 1.5% on the iBench JavaScript test
* kjs/ustring.cpp: (UString::from): Stop using sprintf to format integers.
2002-11-18 Darin Adler <darin@apple.com>
- reduced the creation of Value objects and hoisted the property map
......
2002-11-19 Darin Adler <darin@apple.com>
- a fix that gives another 1.5% on the iBench JavaScript test
* kjs/ustring.cpp: (UString::from): Stop using sprintf to format integers.
2002-11-18 Darin Adler <darin@apple.com>
- reduced the creation of Value objects and hoisted the property map
......
2002-11-19 Darin Adler <darin@apple.com>
- a fix that gives another 1.5% on the iBench JavaScript test
* kjs/ustring.cpp: (UString::from): Stop using sprintf to format integers.
2002-11-18 Darin Adler <darin@apple.com>
- reduced the creation of Value objects and hoisted the property map
......
......@@ -244,26 +244,53 @@ UString::UString(const UString &a, const UString &b)
UString UString::from(int i)
{
char buf[40];
sprintf(buf, "%d", i);
return UString(buf);
return from((long)i);
}
UString UString::from(unsigned int u)
{
char buf[40];
sprintf(buf, "%u", u);
return UString(buf);
UChar buf[20];
UChar *p = buf + sizeof(buf);
if (u == 0) {
*--p = '0';
} else {
while (u) {
*--p = (unsigned short)((u % 10) + '0');
u /= 10;
}
}
return UString(p, buf + sizeof(buf) - p);
}
UString UString::from(long l)
{
char buf[40];
sprintf(buf, "%ld", l);
return UString(buf);
UChar buf[20];
UChar *p = buf + sizeof(buf);
if (l == 0) {
*--p = '0';
} else if (l == LONG_MIN) {
char minBuf[20];
sprintf(minBuf, "%ld", LONG_MIN);
return UString(minBuf);
} else {
bool negative = false;
if (l < 0) {
negative = true;
l = -l;
}
while (l) {
*--p = (unsigned short)((l % 10) + '0');
l /= 10;
}
if (negative) {
*--p = '-';
}
}
return UString(p, buf + sizeof(buf) - p);
}
UString UString::from(double d)
......
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