Skip to content

Commit 056c447

Browse files
Apply suggestions from code review
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 075ecbe commit 056c447

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

keyvi/include/keyvi/dictionary/util/utf8_utils.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,25 @@ class Utf8Utils final {
4848

4949
[[nodiscard]]
5050
static size_t GetCharLength(unsigned char leadByte) {
51-
if ((leadByte & 0x80u) == 0x00u) // 0xxxxxxx
51+
if ((leadByte & 0x80U) == 0x00u) // 0xxxxxxx
52+
if ((leadByte & 0x80u) == 0x00u) { // 0xxxxxxx
5253
return 1;
54+
}
5355

54-
if ((leadByte & 0xE0u) == 0xC0u) // 110xxxxx
56+
if ((leadByte & 0xE0U) == 0xC0u) // 110xxxxx
57+
if ((leadByte & 0xE0u) == 0xC0u) { // 110xxxxx
5558
return 2;
59+
}
5660

57-
if ((leadByte & 0xF0u) == 0xE0u) // 1110xxxx
61+
if ((leadByte & 0xF0U) == 0xE0u) // 1110xxxx
62+
if ((leadByte & 0xF0u) == 0xE0u) { // 1110xxxx
5863
return 3;
64+
}
5965

60-
if ((leadByte & 0xF8u) == 0xF0u) // 11110xxx
66+
if ((leadByte & 0xF8U) == 0xF0u) // 11110xxx
67+
if ((leadByte & 0xF8u) == 0xF0u) { // 11110xxx
6168
return 4;
69+
}
6270

6371
throw std::invalid_argument("Illegal UTF-8 lead byte: " + std::to_string(leadByte));
6472
}

0 commit comments

Comments
 (0)