Skip to content

Commit 2746941

Browse files
committed
Simplify code with else after return
1 parent 1d4b8c3 commit 2746941

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

include/osmium/io/detail/string_util.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,8 @@ namespace osmium {
160160
/* 110XXXXx 10xxxxxx */
161161
if ((s[1] & 0xc0) != 0x80 || (s[0] & 0xfe) == 0xc0) /* overlong? */ {
162162
return reinterpret_cast<char const *>(s);
163-
} else {
164-
s += 2;
165163
}
164+
s += 2;
166165
} else if ((s[0] & 0xf0) == 0xe0) {
167166
/* 1110XXXX 10Xxxxxx 10xxxxxx */
168167
if ((s[1] & 0xc0) != 0x80 || (s[2] & 0xc0) != 0x80 ||
@@ -171,19 +170,17 @@ namespace osmium {
171170
(s[0] == 0xef && s[1] == 0xbf &&
172171
(s[2] & 0xfe) == 0xbe)) /* U+FFFE or U+FFFF? */ {
173172
return reinterpret_cast<char const *>(s);
174-
} else {
175-
s += 3;
176173
}
174+
s += 3;
177175
} else if ((s[0] & 0xf8) == 0xf0) {
178176
/* 11110XXX 10XXxxxx 10xxxxxx 10xxxxxx */
179177
if ((s[1] & 0xc0) != 0x80 || (s[2] & 0xc0) != 0x80 ||
180178
(s[3] & 0xc0) != 0x80 ||
181179
(s[0] == 0xf0 && (s[1] & 0xf0) == 0x80) || /* overlong? */
182180
(s[0] == 0xf4 && s[1] > 0x8f) || s[0] > 0xf4) /* > U+10FFFF? */ {
183181
return reinterpret_cast<char const *>(s);
184-
} else {
185-
s += 4;
186182
}
183+
s += 4;
187184
} else {
188185
return reinterpret_cast<char const *>(s);
189186
}

0 commit comments

Comments
 (0)