Francois Gouget : testbot/lib: Avoid calling DBIBackEnd::GetDb() unnecessarily.

Alexandre Julliard julliard at winehq.org
Mon Oct 29 12:19:47 CDT 2012


Module: tools
Branch: master
Commit: 57d325ba623d5bf8f6a2332eae7990b01f15e151
URL:    http://source.winehq.org/git/tools.git/?a=commit;h=57d325ba623d5bf8f6a2332eae7990b01f15e151

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Mon Oct 29 15:39:47 2012 +0100

testbot/lib: Avoid calling DBIBackEnd::GetDb() unnecessarily.

These calls are a bit more expensive now that they verify that the
connection is still live. So SaveCollection() should really call it
only once.

---

 testbot/lib/ObjectModel/DBIBackEnd.pm |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/testbot/lib/ObjectModel/DBIBackEnd.pm b/testbot/lib/ObjectModel/DBIBackEnd.pm
index 72ff3c5..8af9c8b 100644
--- a/testbot/lib/ObjectModel/DBIBackEnd.pm
+++ b/testbot/lib/ObjectModel/DBIBackEnd.pm
@@ -434,16 +434,17 @@ sub SaveCollection
   my $self = shift;
   my $Collection = shift;
 
+  my $Db = $self->GetDb();
   my ($MasterColNames, $MasterColValues) = $Collection->GetMasterCols();
   my $UpdateQuery = $self->BuildUpdateStatement($Collection->GetTableName(),
                                                 $Collection->GetPropertyDescriptors(),
                                                 $MasterColNames);
-  my $UpdateStatement = $self->GetDb()->prepare($UpdateQuery);
+  my $UpdateStatement = $Db->prepare($UpdateQuery);
 
   my $InsertQuery = $self->BuildInsertStatement($Collection->GetTableName(),
                                                 $Collection->GetPropertyDescriptors(),
                                                 $MasterColNames);
-  my $InsertStatement = $self->GetDb()->prepare($InsertQuery);
+  my $InsertStatement = $Db->prepare($InsertQuery);
 
   foreach my $Key (@{$Collection->GetKeysNoLoad()})
   {
@@ -465,7 +466,7 @@ sub SaveCollection
             die "Sequence property spans multiple columns";
           }
 
-          $Item->PutColValue(@{$ColNames}[0], $self->GetDb()->{'mysql_insertid'});
+          $Item->PutColValue(@{$ColNames}[0], $Db->{'mysql_insertid'});
           $Collection->KeyChanged($Key, $Item->GetKey());
         }
       }




More information about the wine-cvs mailing list