From c7e52048e6cc6adcf1fd5b5195da3937976bd976 Mon Sep 17 00:00:00 2001 From: Tim Kosse Date: Thu, 11 Dec 2014 20:31:31 +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/branches/WX_3_0_BRANCH@78265 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 b2eaa71576..612aeea4da 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -1057,16 +1057,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