stop $foo =~ /(bar)/g skipping copy
Normally in the presence of captures, a successful regex execution
makes a copy of the matched string, so that $1 et al give the right
value even if the original string is changed; i.e.
$foo =~ /(123)/g;
$foo = "bar";
is("$1", "123");
Until now that test would fail, because perl used to skip the copy for
the scalar /(...)/g case (but not the C<$&; //g> case). This was to
avoid a huge slowdown in code like the following:
$x = 'x' x 1_000_000;
1 while $x =~ /(.)/g;
which would otherwise end up copying a 1Mb string a million times.
Now that (with the last commit but one) we copy only the required
substring of the original string (a 1-byte substring in the above
example), we can remove this fast-but-incorrect hack.