Hi,
the question whether map() has the same optimization for scalar context
as it has for void context was raised on clpm. It turned out that it
hasn't and the attached tiny and rather cheap patch puts things right.
The old behaviour was sub-optimal in that pp_mapwhile() made mortal
copies of the returned values in scalar-context. After weeding this out,
scalar-map performs a little better than void-map even (why, btw?):
Rate list void scalar
list 4.74/s -- -57% -60%
void 11.1/s 134% -- -6%
scalar 11.8/s 148% 6% --
as opposed to
Rate list scalar void
list 4.72/s -- -33% -57%
scalar 7.04/s 49% -- -36%
void 11.0/s 133% 57% --
for the three cases
my @a = map $_+1, 1 .. 100000;
my $a = map $_+1, 1 .. 100000;
map $_+1, 1 .. 100000;
Since the values that are put onto the stack (as returned by map) are
meaningless in scalar-context, I used &PL_sv_undef for them. But
anything should do.
Tassilo
PS: I hope the whitespaces are in order this time.
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
Thread Next