From 066579f7d70ac8f00ba57bd90eeadfb0bb952e53 Mon Sep 17 00:00:00 2001 From: Robert Schulze Date: Fri, 15 Dec 2023 15:02:44 +0000 Subject: [PATCH] Improve code aesthetics --- src/Storages/StorageMerge.cpp | 36 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/Storages/StorageMerge.cpp b/src/Storages/StorageMerge.cpp index e10ed689280..ff34d2b175e 100644 --- a/src/Storages/StorageMerge.cpp +++ b/src/Storages/StorageMerge.cpp @@ -1155,40 +1155,36 @@ std::tuple StorageMerge::evaluateDatabaseName(cons bool StorageMerge::supportsTrivialCountOptimization() const { - bool is_support = true; - forEachTable([&](const StoragePtr & table) + bool supported = true; + forEachTable([&](const auto & table) { - is_support &= table->supportsTrivialCountOptimization(); + supported &= table->supportsTrivialCountOptimization(); }); - return is_support; + return supported; } -std::optional StorageMerge::totalRows(const Settings &) const +std::optional StorageMerge::totalRows(const Settings & settings) const { UInt64 total_rows = 0; - forEachTable([&](const StoragePtr & table) + forEachTable([&](const auto & table) { - auto table_rows = table->totalRows(getContext()->getSettingsRef()); - if (table_rows) - { - total_rows += *table_rows; - } + std::optional rows = table->totalRows(settings); + if (rows) + total_rows += *rows; }); - return std::make_optional(total_rows); + return {total_rows}; } -std::optional StorageMerge::totalBytes(const Settings &) const +std::optional StorageMerge::totalBytes(const Settings & settings) const { UInt64 total_bytes = 0; - forEachTable([&](const StoragePtr & table) + forEachTable([&](const auto & table) { - auto table_bytes = table->totalBytes(getContext()->getSettingsRef()); - if (table_bytes) - { - total_bytes += *table_bytes; - } + std::optional bytes = table->totalBytes(settings); + if (bytes) + total_bytes += *bytes; }); - return std::make_optional(total_bytes); + return {total_bytes}; }