[Bast-commits] r6300 -
DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Mon May 18 17:32:42 GMT 2009
Author: ribasushi
Date: 2009-05-18 17:32:42 +0000 (Mon, 18 May 2009)
New Revision: 6300
Modified:
DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/ResultSet.pm
Log:
pager optimization
Modified: DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/ResultSet.pm 2009-05-18 17:27:38 UTC (rev 6299)
+++ DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/ResultSet.pm 2009-05-18 17:32:42 UTC (rev 6300)
@@ -1708,6 +1708,9 @@
sub pager {
my ($self) = @_;
+
+ return $self->{pager} if $self->{pager};
+
my $attrs = $self->{attrs};
$self->throw_exception("Can't create pager for non-paged rs")
unless $self->{attrs}{page};
@@ -1717,10 +1720,13 @@
# with a subselect) to get the real total count
my $count_attrs = { %$attrs };
delete $count_attrs->{$_} for qw/rows offset page pager/;
- my $total_count = (ref $self)->new($self->result_source, $count_attrs);
+ my $total_count = (ref $self)->new($self->result_source, $count_attrs)->count;
- return $self->{pager} ||= Data::Page->new(
- $total_count, $attrs->{rows}, $self->{attrs}{page});
+ return $self->{pager} = Data::Page->new(
+ $total_count,
+ $attrs->{rows},
+ $self->{attrs}{page}
+ );
}
=head2 page
More information about the Bast-commits
mailing list