From: Peter Rabbitson Date: Mon, 7 Jan 2013 13:14:34 +0000 (-0500) Subject: Reduce amount of calls to $rsrc->columns_info where possible X-Git-Tag: v0.08205~19 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a3483a581e58357aa9ef70bee1731e45401dbe82;p=dbsrgits%2FDBIx-Class.git Reduce amount of calls to $rsrc->columns_info where possible --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index a458b09..becaf2b 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1746,9 +1746,7 @@ sub _dbh_execute { } sub _prefetch_autovalues { - my ($self, $source, $to_insert) = @_; - - my $colinfo = $source->columns_info; + my ($self, $source, $colinfo, $to_insert) = @_; my %values; for my $col (keys %$colinfo) { @@ -1778,7 +1776,9 @@ sub _prefetch_autovalues { sub insert { my ($self, $source, $to_insert) = @_; - my $prefetched_values = $self->_prefetch_autovalues($source, $to_insert); + my $col_infos = $source->columns_info; + + my $prefetched_values = $self->_prefetch_autovalues($source, $col_infos, $to_insert); # fuse the values, but keep a separate list of prefetched_values so that # they can be fused once again with the final return @@ -1786,7 +1786,6 @@ sub insert { # FIXME - we seem to assume undef values as non-supplied. This is wrong. # Investigate what does it take to s/defined/exists/ - my $col_infos = $source->columns_info; my %pcols = map { $_ => 1 } $source->primary_columns; my (%retrieve_cols, $autoinc_supplied, $retrieve_autoinc_col); for my $col ($source->columns) { diff --git a/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm b/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm index 834a4d5..b830921 100644 --- a/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm +++ b/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm @@ -45,12 +45,10 @@ sub last_insert_id { shift->_identity } sub _prefetch_autovalues { my $self = shift; - my ($source, $to_insert) = @_; + my ($source, $colinfo, $to_insert) = @_; my $values = $self->next::method(@_); - my $colinfo = $source->columns_info; - my $identity_col = first { $colinfo->{$_}{is_auto_increment} } keys %$colinfo; diff --git a/lib/DBIx/Class/Storage/DBI/UniqueIdentifier.pm b/lib/DBIx/Class/Storage/DBI/UniqueIdentifier.pm index 8621da0..ec83a33 100644 --- a/lib/DBIx/Class/Storage/DBI/UniqueIdentifier.pm +++ b/lib/DBIx/Class/Storage/DBI/UniqueIdentifier.pm @@ -59,9 +59,7 @@ sub _is_guid_type { sub _prefetch_autovalues { my $self = shift; - my ($source, $to_insert) = @_; - - my $col_info = $source->columns_info; + my ($source, $col_info, $to_insert) = @_; my %guid_cols; my @pk_cols = $source->primary_columns;