From 5baab75fd2ae62b6f6407991922fe234f9e73c88 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Thu, 26 Sep 2024 14:20:16 +0200 Subject: Fix redundant std::optional conversions ...proposed by clang-tidy. Enable bugprone-optional-value-conversion check. --- src/buildtool/file_system/git_repo.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/buildtool/file_system/git_repo.cpp') diff --git a/src/buildtool/file_system/git_repo.cpp b/src/buildtool/file_system/git_repo.cpp index 791d5996..f3769008 100644 --- a/src/buildtool/file_system/git_repo.cpp +++ b/src/buildtool/file_system/git_repo.cpp @@ -1686,7 +1686,7 @@ auto GitRepo::GetObjectByPathFromTree(std::string const& tree_id, GetGitCAS()->ReadObject(entry_id, /*is_hex_id=*/true)) { return TreeEntryInfo{.id = entry_id, .type = entry_type, - .symlink_content = *target}; + .symlink_content = std::move(target)}; } Logger::Log( LogLevel::Trace, @@ -1948,11 +1948,7 @@ auto GitRepo::CreateTree(tree_entries_t const& entries) const noexcept GitLastError()); return std::nullopt; } - auto raw_id = ToRawString(oid); - if (not raw_id) { - return std::nullopt; - } - return std::move(*raw_id); + return ToRawString(oid); } catch (std::exception const& ex) { Logger::Log( LogLevel::Error, "creating tree failed with:\n{}", ex.what()); @@ -2104,9 +2100,7 @@ auto GitRepo::CreateTreeFromDirectory(std::filesystem::path const& dir, }; if (ReadDirectory(dir, dir_read_and_store, logger)) { - if (auto raw_id = CreateTree(entries)) { - return *raw_id; - } + return CreateTree(entries); } return std::nullopt; #endif // BOOTSTRAP_BUILD_TOOL -- cgit v1.2.3