in reply to Is it File::Map issue, or another 'helpful' Perl regex optimization?

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 '$&'.

However, the type of string created by File::Map isn't suitable for being COWed, so perl copies the whole string instead.

I'll add it to my list of "things to see if we can improve in COW".

Dave.

  • Comment on Re: Is it File::Map issue, or another 'helpful' Perl regex optimization?