Reverse conditions to make the cheapest condition first.

We don't need to do a count() if the page is not 1.

Refs #3333
This commit is contained in:
mark_story 2014-05-12 22:09:27 -04:00
parent 823f01601d
commit b2207c1ca8

View file

@ -202,8 +202,8 @@ class PaginatorComponent extends Component {
$count = 0;
} elseif ($object->hasMethod('paginateCount')) {
$count = $object->paginateCount($conditions, $recursive, $extra);
} elseif (count($results) < $limit && $page==1) {
$count = count($results); // no point in finding the count if it's less than our limit and we're on the first page
} elseif ($page === 1 && count($results) < $limit) {
$count = count($results);
} else {
$parameters = compact('conditions');
if ($recursive != $object->recursive) {