Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
…void multiple internal calls to methods when values are already cached in `$pages`
  • Loading branch information
Ocramius committed Dec 5, 2014
1 parent 1792754 commit d53f416
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -916,10 +916,13 @@ protected function _createPages($scrollingStyle = null)
// Item numbers
if ($this->getCurrentItems() !== null) {
$pages->currentItemCount = $this->getCurrentItemCount();
$pages->itemCountPerPage = $this->getItemCountPerPage();
$pages->totalItemCount = $this->getTotalItemCount();
$pages->firstItemNumber = $this->getTotalItemCount() ? (($currentPageNumber - 1) * $this->getItemCountPerPage()) + 1 : 0;
$pages->lastItemNumber = $this->getTotalItemCount() ? $pages->firstItemNumber + $pages->currentItemCount - 1 : 0;
$pages->firstItemNumber = $pages->totalItemCount
? (($currentPageNumber - 1) * $pages->itemCountPerPage) + 1
: 0;
$pages->lastItemNumber = $pages->totalItemCount
? $pages->firstItemNumber + $pages->currentItemCount - 1
: 0;
}

return $pages;
Expand Down

0 comments on commit d53f416

Please sign in to comment.