Browse Source

Reverse conditions to make the cheapest condition first.

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

Refs #3333
mark_story 12 years ago
parent
commit
b2207c1ca8
1 changed files with 2 additions and 2 deletions
  1. 2 2
      lib/Cake/Controller/Component/PaginatorComponent.php

+ 2 - 2
lib/Cake/Controller/Component/PaginatorComponent.php

@@ -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) {