perl5 icon indicating copy to clipboard operation
perl5 copied to clipboard

bytes_from_utf8_loc: Move declarations, rename variable

Open khwilliamson opened this issue 1 year ago • 0 comments

Now that we have c99, we can declare close to first use. s0 seems to be the more common name for a variable that preserves the position a string 's' had on input. This also adds a const to make sure the function doesn't change s0. bytes_from_utf8: Copy initial invariants as-is

 The paradigm used in this commit is in place in several other places in
 core.  When dealing with UTF-8, it may well be that the first part of a
 string contains only characters that are the same when encoded as UTF-8
 as when not.  There is a function that finds the first position in a
 string not like that.  It works on a whole word at a time instead of
 per-byte, effectively speeding things up by a factor of 8.
 
 In this case, calling that function tells us that we can use memcpy() to
 do the initial part of our task, before having to switch to looking at
 individual bytes.

  • This set of changes does not require a perldelta entry.

khwilliamson avatar Oct 01 '24 23:10 khwilliamson