summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2017-11-18 16:36:45 -0700
committerKarl Williamson <khw@cpan.org>2017-11-24 22:10:52 -0700
commit8cd29efcae02781bf1c9843e66b7b08105659d6b (patch)
tree307775582aa6cdb62e514a8443f1f5cb57128cf7 /pp_sys.c
parentc7f61edaeb9bf126c6c222500d3350ccfced3e3f (diff)
downloadperl-8cd29efcae02781bf1c9843e66b7b08105659d6b.tar.gz
pp_sys.c: Avoid reparsing string
By using is_utf8_invariant_string_loc() instead of plain is_utf8_invariant_string(), we can start parsing at the first variant (if any is found) instead of the previous behavior of starting again at the beginning of the string.
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/pp_sys.c b/pp_sys.c
index a66cb4ec94..a3caf01c65 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -3499,6 +3499,7 @@ PP(pp_fttext)
SV *sv = NULL;
GV *gv;
PerlIO *fp;
+ const U8 * first_variant;
tryAMAGICftest_MG(PL_op->op_type == OP_FTTEXT ? 'T' : 'B');
@@ -3632,11 +3633,14 @@ PP(pp_fttext)
#endif
assert(len);
- if (! is_utf8_invariant_string((U8 *) s, len)) {
+ if (! is_utf8_invariant_string_loc((U8 *) s, len, &first_variant)) {
/* Here contains a variant under UTF-8 . See if the entire string is
* UTF-8. */
- if (is_utf8_fixed_width_buf_flags((U8 *) s, len, 0)) {
+ if (is_utf8_fixed_width_buf_flags(first_variant,
+ len - ((char *) first_variant - s),
+ 0))
+ {
if (PL_op->op_type == OP_FTTEXT) {
FT_RETURNYES;
}