Re: SUBSTR() with replacement or lvalue performance issues



Ilya Zakharevich <nospam-abuse@xxxxxxxxx> wrote:
[A complimentary Cc of this posting was NOT [per weedlist] sent to
Michele Dondi
<bik.mido@xxxxxxxxxxxxx>], who wrote in article
<bs38h49bu6oanughiuvgdgr8rfen2v8fh0@xxxxxxx>:
ISTR that the lvaluedness of substr()'s return value, as long as the
fact that you can EVEN take references of it and modify the string
with a sort of action-at-distance was put there specifically for
performance issues. At some point there were problems with
substitutions having a lenght larger than the substituted IalsoIRC,
but they should be solved in recent enough perls.

See: <http://perlmonks.org/?node_id=498434>

Simple experiments show that it is still buggy with 5.8.8: code below
returns

....


change_nth 7, 'lazy', map{ substr $bigScalar, $_->[0], $_->[1] }
[0,3], [4,5], [10,5], [16,3], [20,5], [26,4], [31,3], [35,4], [40,3];
print "$bigScalar\n";

I don't see this as a bug with substr. "Map" doesn't alias the values
it returns, it copies them. So the magic is no longer there, just as it
isn't present in $x if you do:
my $x=substr $bigScalar, 1, 4;

So if it's a bug, it is a bug with map, not substr.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
.



Relevant Pages