Open matyalatte opened 2 months ago
I am honestly more surprised that the code does not use the WinAPI MultiByteToWideChar
and WideCharToMultiByte
functions. Not sure if these would be faster or slower.
I am honestly more surprised that the code does not use the WinAPI MultiByteToWideChar and WideCharToMultiByte functions.
libui used them at alpha3.5 but andlabs replaced them with his own library (andlabs/utf) to support uiAttributedString
.
toUTF16
andtoUTF8
have redundant codes.They call a converter to calculate a buffer size, and call it again to do the actual conversion. They can be faster with dedicated functions for size calculation. Also, they use UTF32 converters internally. I mean,
toUTF8
has two steps: "UTF16 to UTF32" and "UTF32 to UTF8." It can remove many conditional branches (especially for ASCII characters) with a true "UTF16 to UTF8" function.For example,
uiprivUTF16UTF8Count
can be simplified like this.It is a low priority because the current implementation is fast enough for me, but someone should work on it in the future.