summaryrefslogtreecommitdiff
path: root/doop.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2017-11-22 15:39:13 -0700
committerKarl Williamson <khw@cpan.org>2017-11-23 14:18:51 -0700
commit40b85b808db0f3032a304d8d25831f80bb7a83b9 (patch)
treeec15c893ef28e068d56b496432024dbbdb1b491d /doop.c
parente17544a60909ed9555c0dad7cd24afc40eb736e7 (diff)
downloadperl-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.c36
1 files changed, 9 insertions, 27 deletions
diff --git a/doop.c b/doop.c
index 5234e26a65..22942818f1 100644
--- a/doop.c
+++ b/doop.c
@@ -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;