diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-09-16 11:19:11 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-09-18 16:47:40 +0200 |
commit | 10d97aee7d2cdf4c5ea425491786fe9e59360299 (patch) | |
tree | 8a97ea8870815ab542bd636896e6f4819813b85f /src/buildtool/execution_api/common/tree_reader_utils.cpp | |
parent | 1d748c1808e17998b4183574e3706ef1f7b6a5db (diff) | |
download | justbuild-10d97aee7d2cdf4c5ea425491786fe9e59360299.tar.gz |
TreeReaderUtils: change InfoStoreFunc interface
...passing constructed Artifact::ObjectInfo by rvalue, to avoid additional copies.
Diffstat (limited to 'src/buildtool/execution_api/common/tree_reader_utils.cpp')
-rw-r--r-- | src/buildtool/execution_api/common/tree_reader_utils.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/buildtool/execution_api/common/tree_reader_utils.cpp b/src/buildtool/execution_api/common/tree_reader_utils.cpp index 13775201..a04b9300 100644 --- a/src/buildtool/execution_api/common/tree_reader_utils.cpp +++ b/src/buildtool/execution_api/common/tree_reader_utils.cpp @@ -16,6 +16,7 @@ #include <exception> #include <type_traits> +#include <utility> #include "nlohmann/json.hpp" #include "src/buildtool/common/artifact_digest.hpp" @@ -68,11 +69,11 @@ template <typename TTree> auto json = nlohmann::json::object(); TreeReaderUtils::InfoStoreFunc store_infos = [&json](std::filesystem::path const& path, - Artifact::ObjectInfo const& info) -> bool { + Artifact::ObjectInfo&& info) -> bool { static constexpr bool kSizeUnknown = std::is_same_v<TTree, GitRepo::tree_entries_t>; - json[path.string()] = info.ToString(kSizeUnknown); + json[path.string()] = std::move(info).ToString(kSizeUnknown); return true; }; @@ -99,8 +100,8 @@ auto TreeReaderUtils::ReadObjectInfos(bazel_re::Directory const& dir, HashFunction const hash_function{HashFunction::Type::PlainSHA256}; try { for (auto const& f : dir.files()) { - auto const info = CreateObjectInfo(hash_function, f); - if (not info or not store_info(f.name(), *info)) { + auto info = CreateObjectInfo(hash_function, f); + if (not info or not store_info(f.name(), *std::move(info))) { return false; } } @@ -117,8 +118,8 @@ auto TreeReaderUtils::ReadObjectInfos(bazel_re::Directory const& dir, } } for (auto const& d : dir.directories()) { - auto const info = CreateObjectInfo(hash_function, d); - if (not store_info(d.name(), *info)) { + auto info = CreateObjectInfo(hash_function, d); + if (not info or not store_info(d.name(), *std::move(info))) { return false; } } |