Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: ffea7477df4e15160658e87a1a6cf24280f24e29
      
https://github.com/Perl/perl5/commit/ffea7477df4e15160658e87a1a6cf24280f24e29
  Author: Karl Williamson <[email protected]>
  Date:   2021-06-28 (Mon, 28 Jun 2021)

  Changed paths:
    M inline.h

  Log Message:
  -----------
  Avoid some conditionals in is...UTF8_CHAR()

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.


Reply via email to