Skip to content
Permalink
Browse files

Reverse conditions to make the cheapest condition first.

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

Refs #3333
  • Loading branch information...
markstory committed May 13, 2014
1 parent 823f016 commit b2207c1ca880fca143a203d7a9f63d4fa62ca0e7
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/Cake/Controller/Component/PaginatorComponent.php
@@ -202,8 +202,8 @@ public function paginate($object = null, $scope = array(), $whitelist = array())
$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) {

0 comments on commit b2207c1

Please sign in to comment.
You can’t perform that action at this time.