in reply to Re: Access via substr refs 2000 times slower
in thread Access via substr refs 2000 times slower
Trouble is, either of those cause copying of the referenced substring. Effectively just giving you a reference to an anonymous scalar that is a copy of the substring. You might just as well do:
my $substr = substr $bigstring, $start, $length; func( \$substr );
The purpose of taking a substr ref was to avoid copying large chunks of large string, and allow the large string to be modified in place via that reference.
That said. It seems that taking an (lvalue) substr ref also also triggers copying these days. Albeit with attached magic that means that changes made to the copy also get applied to the original substring. Which is a bit cockeyed.
It never used to, but obviously has for some time--at least since 5.8.6. I'm surprised that I've never noticed it before now. It kind of devalues the purpose of taking a reference to a substring. Methinks whomever made the change did not really get Lvalue refs.
I feel the need to write some XS to (again), give me the ability to to pass a reference to a substring around with causing that substring to be copied.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Access via substr refs 2000 times slower
by ikegami (Patriarch) on Dec 28, 2008 at 13:15 UTC | |
|
Re^3: Access via substr refs 2000 times slower
by tilly (Archbishop) on Dec 28, 2008 at 18:58 UTC | |
by BrowserUk (Patriarch) on Dec 28, 2008 at 21:39 UTC | |
by ikegami (Patriarch) on Dec 29, 2008 at 00:29 UTC |