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;
    }
  },
});


_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to