You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These three functions to determine if the next bit of a string is UTF-8
(constrained in three different ways) have basically the same short
loop.
One of the initial conditions in the while() is always true the first
time around. By moving that condition to the middle of the loop, we
avoid it for the common case where the loop is executed just once. This
is when the input is a UTF-8 invariant character (ASCII on ASCII
platforms).
If the functions were constrained to require the first byte pointed to
by the input to exist, the while() could be a do {} while(), and there
would be no extra conditional in calling this vs checking if the next
character is invariant, and if not calling this. And there would be
fewer conditionals for the case of 2 or more bytes in the character.
0 commit comments