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
This commit is contained in:
Tim Kosse
2014-12-11 20:31:21 +00:00
parent def8247c61
commit d9d6247f37

View File

@@ -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