Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small optimisations to Archiving performance #18156

Merged
merged 4 commits into from Oct 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 11 additions & 9 deletions core/DataTable/Row.php
Expand Up @@ -473,6 +473,7 @@ private function isSummableColumn($columnName)
*/
public function sumRow(Row $rowToSum, $enableCopyMetadata = true, $aggregationOperations = false)
{
$operationsIsArray = is_array($aggregationOperations);
foreach ($rowToSum as $columnToSumName => $columnToSumValue) {
if (!$this->isSummableColumn($columnToSumName)) {
continue;
Expand All @@ -481,11 +482,12 @@ public function sumRow(Row $rowToSum, $enableCopyMetadata = true, $aggregationOp
$thisColumnValue = $this->getColumn($columnToSumName);

$operation = 'sum';
if (is_array($aggregationOperations) && isset($aggregationOperations[$columnToSumName])) {
if (is_string($aggregationOperations[$columnToSumName])) {
$operation = strtolower($aggregationOperations[$columnToSumName]);
} elseif (is_callable($aggregationOperations[$columnToSumName])) {
$operation = $aggregationOperations[$columnToSumName];
if ($operationsIsArray && isset($aggregationOperations[$columnToSumName])) {
$operationName = $aggregationOperations[$columnToSumName];
if (is_string($operationName)) {
$operation = strtolower($operationName);
} elseif (is_callable($operationName)) {
$operation = $operationName;
}
}

Expand Down Expand Up @@ -650,6 +652,10 @@ public function setComparisons(DataTable $table)
*/
protected function sumRowArray($thisColumnValue, $columnToSumValue, $columnName = null)
{
if ($columnToSumValue === false) {
return $thisColumnValue;
}

if (is_numeric($columnToSumValue)) {
if ($thisColumnValue === false) {
$thisColumnValue = 0;
Expand All @@ -664,10 +670,6 @@ protected function sumRowArray($thisColumnValue, $columnToSumValue, $columnName
return $thisColumnValue + $columnToSumValue;
}

if ($columnToSumValue === false) {
return $thisColumnValue;
}

if ($thisColumnValue === false) {
return $columnToSumValue;
}
Expand Down