diff options
author | Kurt Korbatits <kurt.korbatits@nokia.com> | 2010-02-07 23:53:17 (GMT) |
---|---|---|
committer | Kurt Korbatits <kurt.korbatits@nokia.com> | 2010-02-07 23:53:17 (GMT) |
commit | ac33de5bf257eb215a09c232d950be265d57d22f (patch) | |
tree | 3947891872c1a41deaa32e8995e2e233548b3352 /src/corelib/tools | |
parent | 3108f02f35685bd57486e198277c600e09d98b13 (diff) | |
parent | 8ca95cbc98a97a8208120e4aa76bfd5c16b01df9 (diff) | |
download | Qt-ac33de5bf257eb215a09c232d950be265d57d22f.zip Qt-ac33de5bf257eb215a09c232d950be265d57d22f.tar.gz Qt-ac33de5bf257eb215a09c232d950be265d57d22f.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt-multimedia-team into 4.6
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qhash.cpp | 8 | ||||
-rw-r--r-- | src/corelib/tools/qlist.cpp | 2 | ||||
-rw-r--r-- | src/corelib/tools/qstring.cpp | 15 |
3 files changed, 18 insertions, 7 deletions
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..3ef0e66 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 fromUtf16((const ushort *)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); } |