This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
bytes_from_utf8(): Use memcpy if all invariant
authorKarl Williamson <khw@cpan.org>
Mon, 5 Jun 2017 18:26:06 +0000 (12:26 -0600)
committerKarl Williamson <khw@cpan.org>
Thu, 8 Jun 2017 17:04:43 +0000 (11:04 -0600)
commit170a1c22f1ad3af58230b4637da03f807a9efa56
tree068dd5ad4f05fe8b835042d8e80a07f9262d9d72
parent2a67563b073377398a953d7df7d276295521bfa6
bytes_from_utf8(): Use memcpy if all invariant

This function does two passes over the input.  In the first it decides
if the string can be downgraded, and computes the size needed for the
downgraded string.  In the 2nd pass, it does the conversion.

Adding a single 'if' to the function can bypass the 2nd pass completely
if only invariants are found.  The 2nd pass is replaced by a memcpy().
utf8.c