summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-02-02 10:16:50 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-02-02 10:16:50 (GMT)
commit037a3d01cbb0655a9d822a48f579bb346a0ef2c9 (patch)
tree8afd046bcf8d2e8281f3a0202cd0e366c273aa29 /src
parent57d33781bd8e02904a85de7fc54f8f4e8bd299e6 (diff)
parent470b2de3e24b8eca056a31728a5e1039a9a25d79 (diff)
downloadQt-037a3d01cbb0655a9d822a48f579bb346a0ef2c9.zip
Qt-037a3d01cbb0655a9d822a48f579bb346a0ef2c9.tar.gz
Qt-037a3d01cbb0655a9d822a48f579bb346a0ef2c9.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/berlin-staging-1 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/berlin-staging-1: qmake: subdirs template: make distclean target use QMAKE_DISTCLEAN qmake: fix warnings qmake: Remove macro and simplify string expression previously using it qmake: use isActiveConfig() instead of hand-crafting comparisons Fix missing namespace. Assistant: Fix spelling mistakes. Assistant: Use const references in foreach loops. optimization: get rid of QString::fromUtf16() usage document QString::fromUtf16() slowness remove duplicated calculation of length remove pointless conditionals micro-optimization optimize qhash() Designer/uic/related examples: Fix source code scanning issues II.
Diffstat (limited to 'src')
-rw-r--r--src/corelib/codecs/qutfcodec.cpp7
-rw-r--r--src/corelib/io/qprocess_unix.cpp2
-rw-r--r--src/corelib/kernel/qcore_symbian_p.cpp2
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp3
-rw-r--r--src/corelib/kernel/qtranslator.cpp2
-rw-r--r--src/corelib/tools/qhash.cpp8
-rw-r--r--src/corelib/tools/qlist.cpp2
-rw-r--r--src/corelib/tools/qstring.cpp15
-rw-r--r--src/gui/itemviews/qitemdelegate.cpp2
-rw-r--r--src/gui/kernel/qclipboard_s60.cpp3
-rw-r--r--src/gui/kernel/qdnd_x11.cpp2
-rw-r--r--src/gui/kernel/qmime_mac.cpp4
-rw-r--r--src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp4
-rw-r--r--src/sql/drivers/sqlite/qsql_sqlite.cpp4
-rw-r--r--src/sql/kernel/qsqlresult.cpp2
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.cpp6
-rw-r--r--src/tools/uic3/converter.cpp6
-rw-r--r--src/tools/uic3/main.cpp4
18 files changed, 47 insertions, 31 deletions
diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp
index f7d3b06..7655c51 100644
--- a/src/corelib/codecs/qutfcodec.cpp
+++ b/src/corelib/codecs/qutfcodec.cpp
@@ -326,11 +326,11 @@ QString QUtf16::convertToUnicode(const char *chars, int len, QTextCodec::Convert
ch.setCell(*chars++);
}
if (!headerdone) {
+ headerdone = true;
if (endian == DetectEndianness) {
- if (ch == QChar::ByteOrderSwapped && endian != BigEndianness) {
+ if (ch == QChar::ByteOrderSwapped) {
endian = LittleEndianness;
- } else if (ch == QChar::ByteOrderMark && endian != LittleEndianness) {
- // ignore BOM
+ } else if (ch == QChar::ByteOrderMark) {
endian = BigEndianness;
} else {
if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
@@ -344,7 +344,6 @@ QString QUtf16::convertToUnicode(const char *chars, int len, QTextCodec::Convert
} else if (ch != QChar::ByteOrderMark) {
*qch++ = ch;
}
- headerdone = true;
} else {
*qch++ = ch;
}
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 0bf7d3f..5119ec0 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -783,7 +783,7 @@ bool QProcessPrivate::processStarted()
// did we read an error message?
if (i > 0)
- q_func()->setErrorString(QString::fromUtf16(buf, i / sizeof(QChar)));
+ q_func()->setErrorString(QString((const QChar *)buf, i / sizeof(QChar)));
return i <= 0;
}
diff --git a/src/corelib/kernel/qcore_symbian_p.cpp b/src/corelib/kernel/qcore_symbian_p.cpp
index 5d2a6a5..0257ac4 100644
--- a/src/corelib/kernel/qcore_symbian_p.cpp
+++ b/src/corelib/kernel/qcore_symbian_p.cpp
@@ -71,7 +71,7 @@ Q_CORE_EXPORT QString qt_TDesC2QString(const TDesC& aDescriptor)
#ifdef QT_NO_UNICODE
return QString::fromLocal8Bit(aDescriptor.Ptr(), aDescriptor.Length());
#else
- return QString::fromUtf16(aDescriptor.Ptr(), aDescriptor.Length());
+ return QString(reinterpret_cast<const QChar *>(aDescriptor.Ptr()), aDescriptor.Length());
#endif
}
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 005dedc..5c65416 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -2219,7 +2219,8 @@ QStringList QCoreApplication::libraryPaths()
TFindFile finder(fs);
TInt err = finder.FindByDir(tempPathPtr, tempPathPtr);
while (err == KErrNone) {
- QString foundDir = QString::fromUtf16(finder.File().Ptr(), finder.File().Length());
+ QString foundDir(reinterpret_cast<const QChar *>(finder.File().Ptr()),
+ finder.File().Length());
foundDir = QDir(foundDir).canonicalPath();
if (!app_libpaths->contains(foundDir))
app_libpaths->append(foundDir);
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index b7e6ea0..7d1e1d3 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -633,7 +633,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
end:
if (!tn)
return QString();
- QString str = QString::fromUtf16((const ushort *)tn, tn_length/2);
+ QString str = QString((const QChar *)tn, tn_length/2);
if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
for (int i = 0; i < str.length(); ++i)
str[i] = QChar((str.at(i).unicode() >> 8) + ((str.at(i).unicode() << 8) & 0xff00));
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index d758325..6231471 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -68,8 +68,8 @@ static uint hash(const uchar *p, int n)
while (n--) {
h = (h << 4) + *p++;
- if ((g = (h & 0xf0000000)) != 0)
- h ^= g >> 23;
+ g = h & 0xf0000000;
+ h ^= g >> 23;
h &= ~g;
}
return h;
@@ -82,8 +82,8 @@ static uint hash(const QChar *p, int n)
while (n--) {
h = (h << 4) + (*p++).unicode();
- if ((g = (h & 0xf0000000)) != 0)
- h ^= g >> 23;
+ g = h & 0xf0000000;
+ h ^= g >> 23;
h &= ~g;
}
return h;
diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp
index f1df9bd..c302857 100644
--- a/src/corelib/tools/qlist.cpp
+++ b/src/corelib/tools/qlist.cpp
@@ -208,7 +208,7 @@ void **QListData::append2(const QListData& l)
int n = l.d->end - l.d->begin;
if (n) {
if (e + n > d->alloc)
- realloc(grow(e + l.d->end - l.d->begin));
+ realloc(grow(e + n));
d->end += n;
}
return d->array + e;
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index b9dd4d1..3388500 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -885,7 +885,7 @@ int QString::grow(int size)
QString QString::fromWCharArray(const wchar_t *string, int size)
{
if (sizeof(wchar_t) == sizeof(QChar)) {
- return fromUtf16((ushort *)string, size);
+ return QString((const QChar *)string, size);
} else {
return fromUcs4((uint *)string, size);
}
@@ -3857,6 +3857,12 @@ QString QString::fromUtf8(const char *str, int size)
If \a size is -1 (default), \a unicode must be terminated
with a 0.
+ This function checks for a Byte Order Mark (BOM). If it is missing,
+ host byte order is assumed.
+
+ This function is comparatively slow.
+ Use QString(const ushort *, int) if possible.
+
QString makes a deep copy of the Unicode data.
\sa utf16(), setUtf16()
@@ -3923,6 +3929,9 @@ QString& QString::setUnicode(const QChar *unicode, int size)
If \a unicode is 0, nothing is copied, but the string is still
resized to \a size.
+ Note that unlike fromUtf16(), this function does not consider BOMs and
+ possibly differing byte ordering.
+
\sa utf16(), setUnicode()
*/
@@ -4669,6 +4678,8 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1,
Returns the QString as a '\\0\'-terminated array of unsigned
shorts. The result remains valid until the string is modified.
+ The returned string is in host byte order.
+
\sa unicode()
*/
@@ -7740,7 +7751,7 @@ QString QStringRef::toString() const {
return QString();
if (m_size && m_position == 0 && m_size == m_string->size())
return *m_string;
- return QString::fromUtf16(reinterpret_cast<const ushort*>(m_string->unicode() + m_position), m_size);
+ return QString(m_string->unicode() + m_position, m_size);
}
diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp
index 6fd26a7..9069ce4 100644
--- a/src/gui/itemviews/qitemdelegate.cpp
+++ b/src/gui/itemviews/qitemdelegate.cpp
@@ -1033,7 +1033,7 @@ static QString qPixmapSerial(quint64 i, bool enabled)
i >>= 4;
}
- return QString::fromUtf16(ptr, int(&arr[sizeof(arr) / sizeof(ushort)] - ptr));
+ return QString((const QChar *)ptr, int(&arr[sizeof(arr) / sizeof(ushort)] - ptr));
}
/*!
diff --git a/src/gui/kernel/qclipboard_s60.cpp b/src/gui/kernel/qclipboard_s60.cpp
index 71c355b..f07e066 100644
--- a/src/gui/kernel/qclipboard_s60.cpp
+++ b/src/gui/kernel/qclipboard_s60.cpp
@@ -164,7 +164,8 @@ void readFromStreamLX(QMimeData* aData,RReadStream& aStream)
TCardinality mimeTypeSize;
aStream >> mimeTypeSize;
HBufC* mimeTypeBuf = HBufC::NewLC(aStream,mimeTypeSize);
- QString mimeType = QString::fromUtf16(mimeTypeBuf->Des().Ptr(),mimeTypeBuf->Length());
+ QString mimeType = QString(reinterpret_cast<const QChar *>(mimeTypeBuf->Des().Ptr()),
+ mimeTypeBuf->Length());
CleanupStack::PopAndDestroy(mimeTypeBuf);
// mime data
TCardinality dataSize;
diff --git a/src/gui/kernel/qdnd_x11.cpp b/src/gui/kernel/qdnd_x11.cpp
index edab6a0..33968bd 100644
--- a/src/gui/kernel/qdnd_x11.cpp
+++ b/src/gui/kernel/qdnd_x11.cpp
@@ -617,7 +617,7 @@ QVariant QX11Data::xdndMimeConvertToFormat(Atom a, const QByteArray &data, const
// so it should be safe to check that the second char is 0
// to verify that it is utf16
if (data.size() > 1 && data.at(1) == 0)
- return QString::fromUtf16(reinterpret_cast<const ushort *>(data.constData()),
+ return QString::fromRawData((const QChar *)data.constData(),
data.size() / 2).split(QLatin1Char('\n')).first().toLatin1();
}
}
diff --git a/src/gui/kernel/qmime_mac.cpp b/src/gui/kernel/qmime_mac.cpp
index 0431f2f..071f80d 100644
--- a/src/gui/kernel/qmime_mac.cpp
+++ b/src/gui/kernel/qmime_mac.cpp
@@ -431,8 +431,8 @@ QVariant QMacPasteboardMimeUnicodeText::convertToMime(const QString &mimetype, Q
firstData.size(), CFStringGetSystemEncoding(), false));
ret = QString(str);
} else if (flavor == QLatin1String("public.utf16-plain-text")) {
- ret = QString::fromUtf16(reinterpret_cast<const ushort *>(firstData.constData()),
- firstData.size() / sizeof(ushort));
+ ret = QString(reinterpret_cast<const QChar *>(firstData.constData()),
+ firstData.size() / sizeof(QChar));
} else {
qWarning("QMime::convertToMime: unhandled mimetype: %s", qPrintable(mimetype));
}
diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
index fed1658..6cb76ee 100644
--- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
+++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
@@ -42,6 +42,8 @@
#include "qtextureglyphcache_gl_p.h"
#include "qpaintengineex_opengl2_p.h"
+QT_BEGIN_NAMESPACE
+
#ifdef Q_WS_WIN
extern Q_GUI_EXPORT bool qt_cleartype_enabled;
#endif
@@ -243,3 +245,5 @@ int QGLTextureGlyphCache::glyphMargin() const
return m_type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0;
#endif
}
+
+QT_END_NAMESPACE
diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp
index 9dbefaf..9fff552 100644
--- a/src/sql/drivers/sqlite/qsql_sqlite.cpp
+++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp
@@ -245,9 +245,9 @@ bool QSQLiteResultPrivate::fetchNext(QSqlCachedResult::ValueCache &values, int i
values[i + idx] = QVariant(QVariant::String);
break;
default:
- values[i + idx] = QString::fromUtf16(static_cast<const ushort *>(
+ values[i + idx] = QString(reinterpret_cast<const QChar *>(
sqlite3_column_text16(stmt, i)),
- sqlite3_column_bytes16(stmt, i) / sizeof(ushort));
+ sqlite3_column_bytes16(stmt, i) / sizeof(QChar));
break;
}
}
diff --git a/src/sql/kernel/qsqlresult.cpp b/src/sql/kernel/qsqlresult.cpp
index 5f12b55..3d63f88 100644
--- a/src/sql/kernel/qsqlresult.cpp
+++ b/src/sql/kernel/qsqlresult.cpp
@@ -136,7 +136,7 @@ static QString qFieldSerial(int i)
i >>= 4;
}
- return QString::fromUtf16(arr, int(ptr - arr) + 1);
+ return QString(reinterpret_cast<const QChar *>(arr), int(ptr - arr) + 1);
}
static bool qIsAlnum(QChar ch)
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp
index d9aff1b..8099ffa 100644
--- a/src/tools/uic/cpp/cppwriteinitialization.cpp
+++ b/src/tools/uic/cpp/cppwriteinitialization.cpp
@@ -2787,8 +2787,8 @@ static void generateMultiDirectiveBegin(QTextStream &outputStream, const QSet<QS
return;
QMap<QString, bool> map; // bool is dummy. The idea is to sort that (always generate in the same order) by putting a set into a map
- foreach (QString str, directives)
- map[str] = true;
+ foreach (const QString &str, directives)
+ map.insert(str, true);
if (map.size() == 1) {
outputStream << "#ifndef " << map.constBegin().key() << endl;
@@ -2797,7 +2797,7 @@ static void generateMultiDirectiveBegin(QTextStream &outputStream, const QSet<QS
outputStream << "#if";
bool doOr = false;
- foreach (QString str, map.keys()) {
+ foreach (const QString &str, map.keys()) {
if (doOr)
outputStream << " ||";
outputStream << " !defined(" << str << ')';
diff --git a/src/tools/uic3/converter.cpp b/src/tools/uic3/converter.cpp
index 2bf293d..e1b4b38 100644
--- a/src/tools/uic3/converter.cpp
+++ b/src/tools/uic3/converter.cpp
@@ -401,7 +401,7 @@ DomUI *Ui3Reader::generateUi4(const QDomElement &widget)
bool resolved = false;
if (objName == receiver) {
// see if it's a custom slot
- foreach (QString cs, ui_custom_slots) {
+ foreach (const QString &cs, ui_custom_slots) {
if (cs == slot) {
resolved = true;
break;
@@ -1122,7 +1122,7 @@ void Ui3Reader::createProperties(const QDomElement &n, QList<DomProperty*> *prop
if (prop->kind() == DomProperty::Set) {
QStringList flags = prop->elementSet().split(QLatin1Char('|'));
QStringList v;
- foreach (QString fl, flags) {
+ foreach (const QString &fl, flags) {
QString e = WidgetInfo::resolveEnumerator(className, fl);
if (e.isEmpty()) {
e = m_porting->renameEnumerator(className + QLatin1String("::") + fl);
@@ -1283,7 +1283,7 @@ QString Ui3Reader::fixType(const QString &t) const
QString newText = t;
//split type name on <>*& and whitespace
QStringList typeNames = t.split(QRegExp(QLatin1String("<|>|\\*|&| ")), QString::SkipEmptyParts);
- foreach(QString typeName , typeNames) {
+ foreach(const QString &typeName , typeNames) {
QString newName = fixClassName(typeName);
if( newName != typeName ) {
newText.replace(typeName, newName);
diff --git a/src/tools/uic3/main.cpp b/src/tools/uic3/main.cpp
index 6acc94f..1ebb76a 100644
--- a/src/tools/uic3/main.cpp
+++ b/src/tools/uic3/main.cpp
@@ -338,10 +338,10 @@ int runUic3(int argc, char * argv[])
QStringList globalIncludes, localIncludes;
ui3.computeDeps(e, globalIncludes, localIncludes, impl);
- foreach (QString i, globalIncludes)
+ foreach (const QString &i, globalIncludes)
printf("%s\n", i.toLatin1().constData());
- foreach (QString i, localIncludes)
+ foreach (const QString &i, localIncludes)
printf("%s\n", i.toLatin1().constData());
if (impl)