From dc1db0e8b43f5e907a3ded2e39da8b58fa50a04b Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Wed, 18 Sep 2024 17:51:41 +0200 Subject: Store HashFunction by const reference. Despite the fact that HashFunction is a small type, it still makes sense to store it by reference to reflect the ownership. StorageConfig becomes the main holder. Reference holders store HashFunction by const ref and aren't allowed to change it. However, they are free to return HashFunction by value since this doesn't benefit readability anyhow. --- src/buildtool/execution_engine/executor/executor.hpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/buildtool/execution_engine/executor/executor.hpp') diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp index c9914ab6..9428a6e4 100644 --- a/src/buildtool/execution_engine/executor/executor.hpp +++ b/src/buildtool/execution_engine/executor/executor.hpp @@ -64,7 +64,7 @@ class ExecutorImpl { IExecutionApi const& api, ExecutionProperties const& merged_properties, gsl::not_null const& remote_context, - HashFunction hash_function, + gsl::not_null const& hash_function, std::chrono::milliseconds const& timeout, IExecutionAction::CacheFlag cache_flag, gsl::not_null const& stats, @@ -717,7 +717,8 @@ class ExecutorImpl { [[nodiscard]] static inline auto GetAlternativeEndpoint( const ExecutionProperties& properties, const gsl::not_null& remote_context, - HashFunction hash_function) -> std::unique_ptr { + const gsl::not_null& hash_function) + -> std::unique_ptr { for (auto const& [pred, endpoint] : remote_context->exec_config->dispatch) { bool match = true; @@ -783,7 +784,7 @@ class Executor { context_.remote_context->exec_config->platform_properties, action->ExecutionProperties()), context_.remote_context, - context_.apis->hash_function, + &context_.apis->hash_function, Impl::ScaleTime(timeout_, action->TimeoutScale()), action->NoCache() ? CF::DoNotCacheOutput : CF::CacheOutput, context_.statistics, @@ -806,7 +807,7 @@ class Executor { context_.remote_context->exec_config->platform_properties, action->ExecutionProperties()), context_.remote_context, - context_.apis->hash_function, + &context_.apis->hash_function, Impl::ScaleTime(timeout_, action->TimeoutScale()), action->NoCache() ? CF::DoNotCacheOutput : CF::CacheOutput, context_.statistics, @@ -880,7 +881,7 @@ class Rebuilder { context_.remote_context->exec_config->platform_properties, action->ExecutionProperties()), context_.remote_context, - context_.apis->hash_function, + &context_.apis->hash_function, Impl::ScaleTime(timeout_, action->TimeoutScale()), CF::PretendCached, context_.statistics, @@ -899,7 +900,7 @@ class Rebuilder { context_.remote_context->exec_config->platform_properties, action->ExecutionProperties()), context_.remote_context, - context_.apis->hash_function, + &context_.apis->hash_function, Impl::ScaleTime(timeout_, action->TimeoutScale()), CF::FromCacheOnly, context_.statistics, -- cgit v1.2.3