Skip to content

Commit

Permalink
libcaption: Optimize branch conditons
Browse files Browse the repository at this point in the history
The optimization silences the warning about type limits on platforms
with `char` type as `unsigned char`.

The original condition is semantically identical to the optimized one
because the signed-to-unsigned cast is well-defined in C standard.
  • Loading branch information
r-value committed Aug 5, 2023
1 parent 8feb06f commit dbd22e7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion deps/libcaption/src/utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ size_t utf8_char_length(const utf8_char_t* c)
int utf8_char_whitespace(const utf8_char_t* c)
{
// 0x7F is DEL
if (!c || (c[0] >= 0 && c[0] <= ' ') || c[0] == 0x7F) {
if (!c || (unsigned char)c[0] <= ' ' || c[0] == 0x7F) {
return 1;
}

Expand Down

0 comments on commit dbd22e7

Please sign in to comment.