From 11f80c022fcf6cce17bab95906bd8fc7e5c09747 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 5 Oct 2011 11:53:06 +0200 Subject: [PATCH] Remove duplicate check in utf endian detection MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This was excessive paranoia. Task-number: QTBUG-20482 Change-Id: Ia0c76651773e12f25ec5d62675d6f317b8d2df13 Reviewed-on: http://codereview.qt-project.org/6045 Reviewed-by: Qt Sanity Bot Reviewed-by: Jędrzej Nowacki Reviewed-by: Lars Knoll --- src/corelib/codecs/qutfcodec.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp index aaebec3..34e4695 100644 --- a/src/corelib/codecs/qutfcodec.cpp +++ b/src/corelib/codecs/qutfcodec.cpp @@ -468,20 +468,18 @@ QString QUtf32::convertToUnicode(const char *chars, int len, QTextCodec::Convert if (num == 4) { if (!headerdone) { if (endian == DetectEndianness) { - if (endian == DetectEndianness) { - if (tuple[0] == 0xff && tuple[1] == 0xfe && tuple[2] == 0 && tuple[3] == 0 && endian != BigEndianness) { - endian = LittleEndianness; - num = 0; - continue; - } else if (tuple[0] == 0 && tuple[1] == 0 && tuple[2] == 0xfe && tuple[3] == 0xff && endian != LittleEndianness) { - endian = BigEndianness; - num = 0; - continue; - } else if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { - endian = BigEndianness; - } else { - endian = LittleEndianness; - } + if (tuple[0] == 0xff && tuple[1] == 0xfe && tuple[2] == 0 && tuple[3] == 0 && endian != BigEndianness) { + endian = LittleEndianness; + num = 0; + continue; + } else if (tuple[0] == 0 && tuple[1] == 0 && tuple[2] == 0xfe && tuple[3] == 0xff && endian != LittleEndianness) { + endian = BigEndianness; + num = 0; + continue; + } else if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { + endian = BigEndianness; + } else { + endian = LittleEndianness; } } else if (((endian == BigEndianness) ? qFromBigEndian(tuple) : qFromLittleEndian(tuple)) == QChar::ByteOrderMark) { num = 0; -- 2.7.4