libcaption: Optimize branch conditons

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.
This commit is contained in:
rvalue 2023-08-02 16:38:00 +02:00 committed by Ryan Foster
parent 14db1489e0
commit c96a2a64fc

View file

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