Selaa lähdekoodia

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.
rvalue 2 vuotta sitten
vanhempi
sitoutus
c96a2a64fc
1 muutettua tiedostoa jossa 1 lisäystä ja 1 poistoa
  1. 1 1
      deps/libcaption/src/utf8.c

+ 1 - 1
deps/libcaption/src/utf8.c

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