Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@gmail.com>2015-03-19 22:58:00 +0300
committerThomas Steur <thomas.steur@gmail.com>2015-03-19 22:58:00 +0300
commit46603d8e57e0c231343cb8a2c35e78aa7ba7d4a3 (patch)
tree88a07d94574dcab940925a49053bacc0bd89644d /core/DataTable/Filter/Sort.php
parentaead5ce7f2ab61c786799a411cdc69120fe4550e (diff)
further dataTable performance improvements
Diffstat (limited to 'core/DataTable/Filter/Sort.php')
-rw-r--r--core/DataTable/Filter/Sort.php35
1 files changed, 17 insertions, 18 deletions
diff --git a/core/DataTable/Filter/Sort.php b/core/DataTable/Filter/Sort.php
index 53c21f526a..7f590607cd 100644
--- a/core/DataTable/Filter/Sort.php
+++ b/core/DataTable/Filter/Sort.php
@@ -95,15 +95,12 @@ class Sort extends BaseFilter
/**
* Sorting method used for sorting values natural
*
- * @param array $rowA array[0 => value of column to sort, 1 => label]
- * @param array $rowB array[0 => value of column to sort, 1 => label]
+ * @param mixed $valA
+ * @param mixed $valB
* @return int
*/
- function naturalSort($rowA, $rowB)
+ function naturalSort($valA, $valB)
{
- $valA = $rowA[0];
- $valB = $rowB[0];
-
return !isset($valA)
&& !isset($valB)
? 0
@@ -122,15 +119,12 @@ class Sort extends BaseFilter
/**
* Sorting method used for sorting values
*
- * @param array $rowA array[0 => value of column to sort, 1 => label]
- * @param array $rowB array[0 => value of column to sort, 1 => label]
+ * @param mixed $valA
+ * @param mixed $valB
* @return int
*/
- function sortString($rowA, $rowB)
+ function sortString($valA, $valB)
{
- $valA = $rowA[0];
- $valB = $rowB[0];
-
return !isset($valA)
&& !isset($valB)
? 0
@@ -150,11 +144,10 @@ class Sort extends BaseFilter
{
$value = $row->getColumn($this->columnToSort);
- if ($value === false
- || is_array($value)
- ) {
+ if ($value === false || is_array($value)) {
return null;
}
+
return $value;
}
@@ -239,7 +232,7 @@ class Sort extends BaseFilter
private function getFirstValueFromDataTable($table)
{
- foreach ($table->getRows() as $row) {
+ foreach ($table->getRowsWithoutSummaryRow() as $row) {
$value = $this->getColumnValue($row);
if (!is_null($value)) {
return $value;
@@ -262,8 +255,14 @@ class Sort extends BaseFilter
// get column value and label only once for performance tweak
$values = array();
- foreach ($rows as $key => $row) {
- $values[$key] = array($this->getColumnValue($row), $row->getColumn('label'));
+ if ($functionCallback === 'numberSort') {
+ foreach ($rows as $key => $row) {
+ $values[$key] = array($this->getColumnValue($row), $row->getColumn('label'));
+ }
+ } else {
+ foreach ($rows as $key => $row) {
+ $values[$key] = $this->getColumnValue($row);
+ }
}
uasort($values, array($this, $functionCallback));