Skip to content

Commit

Permalink
bytes_to_utf8: Don't redo work
Browse files Browse the repository at this point in the history
We have gone to some trouble to find the first UTF-8 variant character
in the input string.  There is no need to look again for variants in the
portion of the string that we have already determined doesn't have any
such variants.

This missing statement appears to have been an oversight.
  • Loading branch information
khwilliamson committed Oct 10, 2024
1 parent a5fd0a0 commit 9acaa98
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -2397,14 +2397,14 @@ Perl_utf8_to_bytes(pTHX_ U8 *s, STRLEN *lenp)

U8 * const save = s;
U8 * const send = s + *lenp;
U8 * d;
s = first_variant;

#ifndef EBCDIC /* The below relies on the bit patterns of UTF-8 */

/* There is some start-up/tear-down overhead with this, so no real gain
* unless the string is long enough. The current value is just a
* guess. */
if (*lenp > 5 * PERL_WORDSIZE) {
* unless the remaining portion of the string is long enough. The current
* value is just a guess. */
if ((send - s) > 5 * PERL_WORDSIZE) {

/* First, go through the string a word at-a-time to verify that it is
* downgradable. If it contains any start byte besides C2 and C3, then
Expand Down Expand Up @@ -2517,7 +2517,7 @@ Perl_utf8_to_bytes(pTHX_ U8 *s, STRLEN *lenp)
* and should a malformed one come along, it undoes what it already has
* done */

d = s = first_variant;
U8 * d = s = first_variant;

while (s < send) {
U8 * s1;
Expand Down

0 comments on commit 9acaa98

Please sign in to comment.