From 296ea215b19dcafa06208b258ae7d41c27bd352e Mon Sep 17 00:00:00 2001 From: Toby Cox Date: Wed, 16 Apr 2014 18:28:55 +0100 Subject: [PATCH] Enhancement to paginator No point in finding the count (via model) if the returned result count is less than our limit. We then know that the count is the count of our results --- lib/Cake/Controller/Component/PaginatorComponent.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Cake/Controller/Component/PaginatorComponent.php b/lib/Cake/Controller/Component/PaginatorComponent.php index d848977b1..4be42f7dc 100644 --- a/lib/Cake/Controller/Component/PaginatorComponent.php +++ b/lib/Cake/Controller/Component/PaginatorComponent.php @@ -202,6 +202,8 @@ class PaginatorComponent extends Component { $count = 0; } elseif ($object->hasMethod('paginateCount')) { $count = $object->paginateCount($conditions, $recursive, $extra); + } elseif (count($results)<$limit) { + $count = count($results); // no point in finding the count if it's less than our limit } else { $parameters = compact('conditions'); if ($recursive != $object->recursive) {