This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
avoid disabling utf8 pos cache on tainted strings
RT #130584
When pos() or similar is used on a utf8 string, perl attaches magic
to it that caches a couple of byte<->char offset conversions. This can
avoid quadratic behaviour when continually scanning a big chunk of a long
string to convert a byte offset to a char offset when pos() is called.
v5.17.3-203-g7d1328b added code to invalidate this cache when get magic is
called on an SV, since the get magic may change the value of the SV.
However, under -T, taint magic gets added to a tainted string, which
includes a get method which doesn't actually change the SV's value.
So make a special exception to get-magic-cache-invalidation if the only
get magic on the string is taint.
This stops code like the following going quadratic under -T:
$_ = "... long tainted utf8 string ...";
while ( /..../g) {
my $p = pos(); # calculating pos() goes quadratic
}