summaryrefslogtreecommitdiffstats
path: root/src/corelib
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/corelib
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/corelib')
-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
8 files changed, 26 insertions, 15 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);
}