[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.22-985-g3c00f00
eric at webkit.org
eric at webkit.org
Wed Mar 17 18:26:45 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 51eaf3b3d3a186973d1a47b274e867aefc946e95
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sun Mar 7 08:16:11 2010 +0000
2010-03-07 Jedrzej Nowacki <jedrzej.nowacki at nokia.com>
Reviewed by Simon Hausmann.
Small performance fix in the QScriptConverter::toString().
The QByteArray was replaced by the QVarLengthArray which doesn't
have to allocate any memory on heap.
[Qt] QScriptConverter::toString() should use QVarLengthArray instead of QByteArray
https://bugs.webkit.org/show_bug.cgi?id=35577
* qt/api/qscriptconverter_p.h:
(QScriptConverter::toString):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55634 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 13c2b67..20c4846 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,18 @@
+2010-03-07 Jedrzej Nowacki <jedrzej.nowacki at nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Small performance fix in the QScriptConverter::toString().
+
+ The QByteArray was replaced by the QVarLengthArray which doesn't
+ have to allocate any memory on heap.
+
+ [Qt] QScriptConverter::toString() should use QVarLengthArray instead of QByteArray
+ https://bugs.webkit.org/show_bug.cgi?id=35577
+
+ * qt/api/qscriptconverter_p.h:
+ (QScriptConverter::toString):
+
2010-03-06 Mark Rowe <mrowe at apple.com>
Rubber-stamped by Sam Weinig.
diff --git a/JavaScriptCore/qt/api/qscriptconverter_p.h b/JavaScriptCore/qt/api/qscriptconverter_p.h
index 1c53ec3..cd86e20 100644
--- a/JavaScriptCore/qt/api/qscriptconverter_p.h
+++ b/JavaScriptCore/qt/api/qscriptconverter_p.h
@@ -23,6 +23,7 @@
#include <JavaScriptCore/JavaScript.h>
#include <QtCore/qnumeric.h>
#include <QtCore/qstring.h>
+#include <QtCore/qvarlengtharray.h>
extern char *qdtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve, char **digits_str);
@@ -73,49 +74,58 @@ public:
if (!value)
return QString::fromLatin1("0");
- QByteArray buf;
- buf.reserve(24);
+ QVarLengthArray<char, 25> buf;
int decpt;
int sign;
char* result = 0;
- (void)qdtoa(value, 0, 0, &decpt, &sign, 0, &result);
+ char* endresult;
+ (void)qdtoa(value, 0, 0, &decpt, &sign, &endresult, &result);
if (!result)
return QString();
+ int resultLen = endresult - result;
if (decpt <= 0 && decpt > -6) {
- buf.fill('0', -decpt + 2 + sign);
+ buf.resize(-decpt + 2 + sign);
+ qMemSet(buf.data(), '0', -decpt + 2 + sign);
if (sign) // fix the sign.
buf[0] = '-';
buf[sign + 1] = '.';
- buf += result;
+ buf.append(result, resultLen);
} else {
if (sign)
- buf += '-';
- buf += result;
- int length = buf.length() - sign;
+ buf.append('-');
+ int length = buf.size() - sign + resultLen;
if (decpt <= 21 && decpt > 0) {
- if (length <= decpt)
- buf += QByteArray().fill('0', decpt - length);
- else
- buf.insert(decpt + sign, '.');
+ if (length <= decpt) {
+ const char* zeros = "0000000000000000000000000";
+ buf.append(result, resultLen);
+ buf.append(zeros, decpt - length);
+ } else {
+ buf.append(result, decpt);
+ buf.append('.');
+ buf.append(result + decpt, resultLen - decpt);
+ }
} else if (result[0] >= '0' && result[0] <= '9') {
- if (length > 1)
- buf.insert(1 + sign, '.');
- buf += 'e';
- buf += (decpt >= 0) ? '+' : '-';
- int e = decpt - 1;
- if (e < 0)
- e = -e;
+ if (length > 1) {
+ buf.append(result, 1);
+ buf.append('.');
+ buf.append(result + 1, resultLen - 1);
+ } else
+ buf.append(result, resultLen);
+ buf.append('e');
+ buf.append(decpt >= 0 ? '+' : '-');
+ int e = qAbs(decpt - 1);
if (e >= 100)
- buf += '0' + e / 100;
+ buf.append('0' + e / 100);
if (e >= 10)
- buf += '0' + (e % 100) / 10;
- buf += '0' + e % 10;
+ buf.append('0' + (e % 100) / 10);
+ buf.append('0' + e % 10);
}
}
free(result);
- return QString::fromLatin1(buf);
+ buf.append(0);
+ return QString::fromLatin1(buf.constData());
}
};
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list