diff options
author | Karl Williamson <khw@cpan.org> | 2017-11-22 15:39:13 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2017-11-23 14:18:51 -0700 |
commit | 40b85b808db0f3032a304d8d25831f80bb7a83b9 (patch) | |
tree | ec15c893ef28e068d56b496432024dbbdb1b491d /doop.c | |
parent | e17544a60909ed9555c0dad7cd24afc40eb736e7 (diff) | |
download | perl-40b85b808db0f3032a304d8d25831f80bb7a83b9.tar.gz |
doop.c: Change to use is_utf8_invariant_string()
This commit changes 3 occurrences of byte-at-a-time looking to see if a
string is invariant under UTF-8, to using the inlined
is_utf8_invariant_string() which now does much faster word-at-a-time
looking.
Diffstat (limited to 'doop.c')
-rw-r--r-- | doop.c | 36 |
1 files changed, 9 insertions, 27 deletions
@@ -323,15 +323,9 @@ S_do_trans_simple_utf8(pTHX_ SV * const sv) s = (U8*)SvPV_nomg(sv, len); if (!SvUTF8(sv)) { - const U8 *t = s; - const U8 * const e = s + len; - while (t < e) { - const U8 ch = *t++; - hibit = !NATIVE_BYTE_IS_INVARIANT(ch); - if (hibit) { - s = bytes_to_utf8(s, &len); - break; - } + hibit = ! is_utf8_invariant_string(s, len); + if (hibit) { + s = bytes_to_utf8(s, &len); } } send = s + len; @@ -423,15 +417,9 @@ S_do_trans_count_utf8(pTHX_ SV * const sv) s = (const U8*)SvPV_nomg_const(sv, len); if (!SvUTF8(sv)) { - const U8 *t = s; - const U8 * const e = s + len; - while (t < e) { - const U8 ch = *t++; - hibit = !NATIVE_BYTE_IS_INVARIANT(ch); - if (hibit) { - start = s = bytes_to_utf8(s, &len); - break; - } + hibit = ! is_utf8_invariant_string(s, len); + if (hibit) { + start = s = bytes_to_utf8(s, &len); } } send = s + len; @@ -477,15 +465,9 @@ S_do_trans_complex_utf8(pTHX_ SV * const sv) PERL_ARGS_ASSERT_DO_TRANS_COMPLEX_UTF8; if (!SvUTF8(sv)) { - const U8 *t = s; - const U8 * const e = s + len; - while (t < e) { - const U8 ch = *t++; - hibit = !NATIVE_BYTE_IS_INVARIANT(ch); - if (hibit) { - s = bytes_to_utf8(s, &len); - break; - } + hibit = ! is_utf8_invariant_string(s, len); + if (hibit) { + s = bytes_to_utf8(s, &len); } } send = s + len; |