[Dbix-class] Re: Can't modify prefetch
Peter Rabbitson
rabbit+dbic at rabbit.us
Sun Nov 28 17:26:07 GMT 2010
Tim Bunce wrote:
> On Sat, Nov 27, 2010 at 02:13:48PM +0100, Peter Rabbitson wrote:
>> Ryan Tate wrote:
>>> Nevermind, I stupidly forgot to assign the modified resultset :-) I'll
>>> pull the RT bug too.....
>> Next version will have this so people won't be confused as easily:
>> http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits/DBIx-Class.git;a=commitdiff;h=0e7a447e570daf41c11b403fd81046756894cc27
>
> Micro-optimization: the wantarray op is faster than using a temp variable.
>
Indeed, thanks, will fix :)
Rate var ops
var 121/s -- -19%
ops 148/s 23% --
use strictures 1;
use Benchmark qw/cmpthese/;
my $ops = sub {
if (wantarray) {
1
}
elsif (defined wantarray) {
2
}
else {
3
}
};
my $var = sub {
my $want = wantarray;
if ($want) {
1
}
elsif (defined $want) {
2
}
else {
3
}
};
cmpthese (-1 => {
ops => sub {
for (1..10000) {
$ops->();
1;
}
},
var => sub {
for (1..10000) {
$var->();
1;
}
},
});
More information about the DBIx-Class
mailing list