From: Peter Rabbitson Date: Tue, 11 Mar 2014 06:39:56 +0000 (+0100) Subject: Minimal optimization of the new+prefetch codepath (no func. changes) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2f7aa46c7cbfd235a26863459f80225a72a6e82e;hp=37af2968eb297214614f2f664778305b478e667c;p=dbsrgits%2FDBIx-Class.git Minimal optimization of the new+prefetch codepath (no func. changes) --- diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index 000498a..cad0185 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -1240,17 +1240,15 @@ sub inflate_result { $class->throw_exception("No accessor type declared for prefetched relationship '$relname'") unless $relinfo->{attrs}{accessor}; + my $rel_rs = $new->related_resultset($relname); + my @rel_objects; if ( - $prefetch->{$relname} - and - @{$prefetch->{$relname}} + @{ $prefetch->{$relname} || [] } and ref($prefetch->{$relname}) ne $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) { - my $rel_rs = $new->related_resultset($relname); - if (ref $prefetch->{$relname}[0] eq 'ARRAY') { my $rel_rsrc = $rel_rs->result_source; my $rel_class = $rel_rs->result_class; @@ -1274,7 +1272,7 @@ sub inflate_result { $new->{_inflated_column}{$relname} = $rel_objects[0]; } - $new->related_resultset($relname)->set_cache(\@rel_objects); + $rel_rs->set_cache(\@rel_objects); } }