summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2017-06-05 18:51:28 -0600
committerKarl Williamson <khw@cpan.org>2017-06-08 11:04:43 -0600
commit7f764adcdf933d7a7b77989ac4bd7179ca460cf9 (patch)
treecc7d4e54bfeacd0835c755e5b594789ec0b745c1 /sv.c
parent76d1063ed5ad16ae2d45a83f70269908d502c1a6 (diff)
downloadperl-7f764adcdf933d7a7b77989ac4bd7179ca460cf9.tar.gz
sv.c: Convert to use is_utf8_invariant_string_loc
This inline function was added in the previous commit. And the function has the potential to be sped up by using word-at-a-time operations.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/sv.c b/sv.c
index 2617eba396..4df1224dbd 100644
--- a/sv.c
+++ b/sv.c
@@ -3496,20 +3496,16 @@ Perl_sv_utf8_upgrade_flags_grow(pTHX_ SV *const sv, const I32 flags, STRLEN extr
* incoming SV being well formed and having a trailing '\0', as certain
* code in pp_formline can send us partially built SVs. */
- while (t < e) {
- const U8 ch = *t++;
- if (NATIVE_BYTE_IS_INVARIANT(ch)) continue;
+ if (is_utf8_invariant_string_loc(s, SvCUR(sv), (const U8 **) &t)) {
- t--; /* t already incremented; re-point to first variant */
- two_byte_count = 1;
- goto must_be_utf8;
+ /* utf8 conversion not needed because all are invariants. Mark as
+ * UTF-8 even if no variant - saves scanning loop */
+ SvUTF8_on(sv);
+ if (extra) SvGROW(sv, SvCUR(sv) + extra);
+ return SvCUR(sv);
}
- /* utf8 conversion not needed because all are invariants. Mark as
- * UTF-8 even if no variant - saves scanning loop */
- SvUTF8_on(sv);
- if (extra) SvGROW(sv, SvCUR(sv) + extra);
- return SvCUR(sv);
+ two_byte_count = 1;
must_be_utf8: