From b4d5f05822b3e45442a027121fe5bf66c64c432b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 22 May 2025 12:10:50 -0700 Subject: utf8: use unsigned int in decoder. * utf8.h (utf8_decoder_t): Declare the flags member as well as the buffer indices head, tail and back as unsigned. Bitmask fields holding flags should be unsigned. Regarding the indices, we perform % 8 reductions on them in the decoder, which optimizes much better for unsigned types. --- utf8.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utf8.h b/utf8.h index d0182e97..3300cfbd 100644 --- a/utf8.h +++ b/utf8.h @@ -41,9 +41,9 @@ enum utf8_state { utf8_init, utf8_more1, utf8_more2, utf8_more3 }; typedef struct utf8_decoder { enum utf8_state state; - int flags; + unsigned flags; wchar_t wch, wch_min; - int head, tail, back; + unsigned head, tail, back; int buf[8]; } utf8_decoder_t; -- cgit v1.2.3