[Bast-commits] r4208 - DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage

schwern at dev.catalyst.perl.org schwern at dev.catalyst.perl.org
Sat Mar 15 05:01:47 GMT 2008


Author: schwern
Date: 2008-03-15 05:01:47 +0000 (Sat, 15 Mar 2008)
New Revision: 4208

Modified:
   DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
Log:
Reduce the number of times $self->_dbh is called inside dbh_do() to speed
up that hot bit of code.

Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm	2008-03-15 05:00:56 UTC (rev 4207)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm	2008-03-15 05:01:47 UTC (rev 4208)
@@ -577,7 +577,9 @@
   my $self = shift;
   my $code = shift;
 
-  return $self->$code($self->_dbh, @_) if $self->{_in_dbh_do}
+  my $dbh = $self->_dbh;
+
+  return $self->$code($dbh, @_) if $self->{_in_dbh_do}
       || $self->{transaction_depth};
 
   local $self->{_in_dbh_do} = 1;
@@ -586,16 +588,20 @@
   my $want_array = wantarray;
 
   eval {
-    $self->_verify_pid if $self->_dbh;
-    $self->_populate_dbh if !$self->_dbh;
+    $self->_verify_pid if $dbh;
+    if( !$dbh ) {
+        $self->_populate_dbh;
+        $dbh = $self->_dbh;
+    }
+
     if($want_array) {
-        @result = $self->$code($self->_dbh, @_);
+        @result = $self->$code($dbh, @_);
     }
     elsif(defined $want_array) {
-        $result[0] = $self->$code($self->_dbh, @_);
+        $result[0] = $self->$code($dbh, @_);
     }
     else {
-        $self->$code($self->_dbh, @_);
+        $self->$code($dbh, @_);
     }
   };
 




More information about the Bast-commits mailing list