diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-09-18 17:51:41 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-09-23 10:54:50 +0200 |
commit | dc1db0e8b43f5e907a3ded2e39da8b58fa50a04b (patch) | |
tree | 7ca1dd20806fd71c42f875adc1c653df45b147b1 /src/buildtool/execution_engine/executor/executor.hpp | |
parent | 6453a846e788887b6cd74d71c1873a5e3270434d (diff) | |
download | justbuild-dc1db0e8b43f5e907a3ded2e39da8b58fa50a04b.tar.gz |
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.
Diffstat (limited to 'src/buildtool/execution_engine/executor/executor.hpp')
-rw-r--r-- | src/buildtool/execution_engine/executor/executor.hpp | 13 |
1 files changed, 7 insertions, 6 deletions
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<RemoteContext const*> const& remote_context, - HashFunction hash_function, + gsl::not_null<HashFunction const*> const& hash_function, std::chrono::milliseconds const& timeout, IExecutionAction::CacheFlag cache_flag, gsl::not_null<Statistics*> const& stats, @@ -717,7 +717,8 @@ class ExecutorImpl { [[nodiscard]] static inline auto GetAlternativeEndpoint( const ExecutionProperties& properties, const gsl::not_null<RemoteContext const*>& remote_context, - HashFunction hash_function) -> std::unique_ptr<BazelApi> { + const gsl::not_null<HashFunction const*>& hash_function) + -> std::unique_ptr<BazelApi> { 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, |