sv_len_utf8 is now careful not to record caches on magical or over-
loaded scalars (any non-PV, in fact). It also returns the number of
logical characters correctly, regardless of whether its input is utf8.
So we can greatly simplify this code.
if (lookahead.howlen == e_number) count = lookahead.length;
else {
if (items > 0) {
- if (SvGAMAGIC(*beglist)) {
- /* Avoid reading the active data more than once
- by copying it to a temporary. */
- STRLEN len;
- const char *const pv = SvPV_const(*beglist, len);
- SV *const temp
- = newSVpvn_flags(pv, len,
- SVs_TEMP | SvUTF8(*beglist));
- *beglist = temp;
- }
- count = DO_UTF8(*beglist) ?
- sv_len_utf8(*beglist) : sv_len(*beglist);
+ count = sv_len_utf8(*beglist);
}
else count = 0;
if (lookahead.code == 'Z') count++;