summaryrefslogtreecommitdiff
path: root/src/buildtool/file_system/file_root.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildtool/file_system/file_root.hpp')
-rw-r--r--src/buildtool/file_system/file_root.hpp48
1 files changed, 21 insertions, 27 deletions
diff --git a/src/buildtool/file_system/file_root.hpp b/src/buildtool/file_system/file_root.hpp
index 6a34409c..82e30b89 100644
--- a/src/buildtool/file_system/file_root.hpp
+++ b/src/buildtool/file_system/file_root.hpp
@@ -185,23 +185,14 @@ class FileRoot {
[[nodiscard]] auto ContainsBlob(std::string const& name) const noexcept
-> bool {
- try {
- if (std::holds_alternative<tree_t>(data_)) {
- auto const& data = std::get<tree_t>(data_);
- auto ptr = data->LookupEntryByName(name);
- if (static_cast<bool>(ptr)) {
- return IsBlobObject(ptr->Type());
- }
- return false;
- }
- if (std::holds_alternative<pairs_t>(data_)) {
- auto const& data = std::get<pairs_t>(data_);
- auto it = data.find(name);
- return (it != data.end() and IsBlobObject(it->second));
- }
- } catch (...) {
+ if (auto const* const data = std::get_if<tree_t>(&data_)) {
+ auto const ptr = (*data)->LookupEntryByName(name);
+ return ptr != nullptr and IsBlobObject(ptr->Type());
+ }
+ if (auto const* const data = std::get_if<pairs_t>(&data_)) {
+ auto const it = data->find(name);
+ return it != data->end() and IsBlobObject(it->second);
}
-
return false;
}
@@ -339,18 +330,21 @@ class FileRoot {
std::string const& git_tree_id,
bool ignore_special = false) noexcept
-> std::optional<FileRoot> {
- if (auto cas = GitCAS::Open(repo_path)) {
- if (auto tree = GitTree::Read(cas, git_tree_id, ignore_special)) {
- try {
- return FileRoot{
- cas,
- std::make_shared<GitTree const>(std::move(*tree)),
- ignore_special};
- } catch (...) {
- }
- }
+ auto cas = GitCAS::Open(repo_path);
+ if (not cas) {
+ return std::nullopt;
+ }
+ auto tree = GitTree::Read(cas, git_tree_id, ignore_special);
+ if (not tree) {
+ return std::nullopt;
+ }
+ try {
+ return FileRoot{cas,
+ std::make_shared<GitTree const>(std::move(*tree)),
+ ignore_special};
+ } catch (...) {
+ return std::nullopt;
}
- return std::nullopt;
}
/// \brief Return a complete description of the content of this root, if