note
dave_the_m
In modern perls, copy-on-write (COW) is used to make a "copy" of the string in the case of a successful match.
This copy shares the same string buffer between two scalar values (but unshares them if either scalar value tries to modify its buffer). This avoids the old performance penalty that having $& etc anywhere in your script would impose upon all subsequent matches, while not crashing on something like eval '$&'.
<p>
However, the type of string created by File::Map isn't suitable for being COWed, so perl copies the whole string instead.
<p>
I'll add it to my list of "things to see if we can improve in COW".
<p>
Dave.
1185090
1185090