From 3f75861a2d60fc5a2fd9c9894267f1df72f66c47 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Tue, 25 Jun 2024 16:47:10 +0200 Subject: Use a raw pointer for passing optional RepositoryConfig ...instead of std::optional>. --- src/buildtool/execution_api/local/local_api.hpp | 26 ++++++++++++------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src/buildtool/execution_api/local/local_api.hpp') diff --git a/src/buildtool/execution_api/local/local_api.hpp b/src/buildtool/execution_api/local/local_api.hpp index 8e1964c0..85547de1 100644 --- a/src/buildtool/execution_api/local/local_api.hpp +++ b/src/buildtool/execution_api/local/local_api.hpp @@ -53,9 +53,8 @@ /// \brief API for local execution. class LocalApi final : public IExecutionApi { public: - explicit LocalApi(std::optional> - repo_config = std::nullopt) - : repo_config_{std::move(repo_config)} {} + explicit LocalApi(RepositoryConfig const* repo_config = nullptr) noexcept + : repo_config_{repo_config} {} [[nodiscard]] auto CreateAction( ArtifactDigest const& root_digest, @@ -99,8 +98,8 @@ class LocalApi final : public IExecutionApi { // fall back to git return false; } - if (repo_config_ and - not GitApi(repo_config_.value()) + if (repo_config_ != nullptr and + not GitApi(repo_config_) .RetrieveToPaths({info}, {output_paths[i]})) { return false; } @@ -118,8 +117,8 @@ class LocalApi final : public IExecutionApi { // fall back to git return false; } - if (repo_config_ and - not GitApi(repo_config_.value()) + if (repo_config_ != nullptr and + not GitApi(repo_config_) .RetrieveToPaths({info}, {output_paths[i]})) { return false; } @@ -152,15 +151,15 @@ class LocalApi final : public IExecutionApi { gsl::not_null const& out) { return dumper.DumpToStream(info, out, raw_tree); }, - [&repo_config = repo_config_, &raw_tree]( + [repo_config = repo_config_, &raw_tree]( Artifact::ObjectInfo const& info, int fd) { if (Compatibility::IsCompatible()) { // infos not available, and in compatible mode cannot // fall back to git return false; } - if (repo_config and - not GitApi(repo_config.value()) + if (repo_config != nullptr and + not GitApi(repo_config) .RetrieveToFds({info}, {fd}, raw_tree)) { return false; } @@ -262,9 +261,8 @@ class LocalApi final : public IExecutionApi { if (location) { content = FileSystemManager::ReadFile(*location); } - if ((not content) and repo_config_) { - content = - GitApi(repo_config_.value()).RetrieveToMemory(artifact_info); + if ((not content) and repo_config_ != nullptr) { + content = GitApi(repo_config_).RetrieveToMemory(artifact_info); } return content; } @@ -409,7 +407,7 @@ class LocalApi final : public IExecutionApi { } private: - std::optional> repo_config_{}; + RepositoryConfig const* const repo_config_ = nullptr; gsl::not_null storage_ = &Storage::Instance(); }; -- cgit v1.2.3