From d9d6247f37b9ee7129b0b54998a5fe167841660b Mon Sep 17 00:00:00 2001 From: Tim Kosse Date: Thu, 11 Dec 2014 20:31:21 +0000 Subject: [PATCH] In wxMBConvStrictUTF8::ToWChar the length of a multibyte UTF-8 sequence is obtained from a table, with the leading byte as offset. Later in that function, the prefix of the leading byte is compared against the expected prefix for the given length. Unless the table is faulty, this comparison can never fail. It is thus redundant and not needed. As optimizing compilers aren't smart enough yet to detect this, this commit removes the redundant check. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78264 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/strconv.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index 949f2a71ec..e1e37822f9 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -1051,16 +1051,8 @@ wxMBConvStrictUTF8::ToWChar(wchar_t *dst, size_t dstLen, // length: static const unsigned char leadValueMask[] = { 0x7F, 0x1F, 0x0F, 0x07 }; - // mask and value of lead byte's most significant bits, by length: - static const unsigned char leadMarkerMask[] = { 0x80, 0xE0, 0xF0, 0xF8 }; - static const unsigned char leadMarkerVal[] = { 0x00, 0xC0, 0xE0, 0xF0 }; - len--; // it's more convenient to work with 0-based length here - // extract the lead byte's value bits: - if ( (c & leadMarkerMask[len]) != leadMarkerVal[len] ) - break; - code = c & leadValueMask[len]; // all remaining bytes, if any, are handled in the same way