summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2025-02-27 12:57:13 +0100
committerMaksim Denisov <denisov.maksim@huawei.com>2025-02-28 13:44:06 +0100
commit02bf375f90f16f684cd9b2ac9455001007366f92 (patch)
treeb8e284394aafa9b326359600966ad60adcd57646 /src/buildtool/execution_api
parent2b4e781e2e14653201b81b12e1b332a7462691b7 (diff)
downloadjustbuild-02bf375f90f16f684cd9b2ac9455001007366f92.tar.gz
Avoid rehashing content when using GitRepo::ReadTreeData
Diffstat (limited to 'src/buildtool/execution_api')
-rw-r--r--src/buildtool/execution_api/local/local_cas_reader.cpp9
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp4
-rw-r--r--src/buildtool/execution_api/utils/TARGETS1
-rw-r--r--src/buildtool/execution_api/utils/subobject.cpp9
4 files changed, 9 insertions, 14 deletions
diff --git a/src/buildtool/execution_api/local/local_cas_reader.cpp b/src/buildtool/execution_api/local/local_cas_reader.cpp
index 58af1cbd..9af9650a 100644
--- a/src/buildtool/execution_api/local/local_cas_reader.cpp
+++ b/src/buildtool/execution_api/local/local_cas_reader.cpp
@@ -120,11 +120,10 @@ auto LocalCasReader::ReadGitTree(ArtifactDigest const& digest) const noexcept
// Git-SHA1 hashing is used for reading from git.
HashFunction const hash_function{HashFunction::Type::GitSHA1};
- return GitRepo::ReadTreeData(
- *content,
- hash_function.HashTreeData(*content).Bytes(),
- check_symlinks,
- /*is_hex_id=*/false);
+ return GitRepo::ReadTreeData(*content,
+ digest.hash(),
+ check_symlinks,
+ /*is_hex_id=*/true);
}
}
Logger::Log(LogLevel::Debug, "Tree {} not found in CAS", digest.hash());
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
index 4dda2425..892cf3d9 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
@@ -113,9 +113,9 @@ auto BazelNetworkReader::ReadGitTree(ArtifactDigest const& digest)
};
return GitRepo::ReadTreeData(*content,
- hash_function_.HashTreeData(*content).Bytes(),
+ digest.hash(),
check_symlinks,
- /*is_hex_id=*/false);
+ /*is_hex_id=*/true);
}
auto BazelNetworkReader::DumpRawTree(Artifact::ObjectInfo const& info,
diff --git a/src/buildtool/execution_api/utils/TARGETS b/src/buildtool/execution_api/utils/TARGETS
index 35601176..f9aafff2 100644
--- a/src/buildtool/execution_api/utils/TARGETS
+++ b/src/buildtool/execution_api/utils/TARGETS
@@ -11,7 +11,6 @@
[ ["@", "gsl", "", "gsl"]
, ["src/buildtool/common", "bazel_types"]
, ["src/buildtool/common", "protocol_traits"]
- , ["src/buildtool/crypto", "hash_function"]
, ["src/buildtool/execution_api/bazel_msg", "bazel_msg_factory"]
, ["src/buildtool/execution_api/common", "common"]
, ["src/buildtool/file_system", "git_repo"]
diff --git a/src/buildtool/execution_api/utils/subobject.cpp b/src/buildtool/execution_api/utils/subobject.cpp
index f1b1b459..466c3b73 100644
--- a/src/buildtool/execution_api/utils/subobject.cpp
+++ b/src/buildtool/execution_api/utils/subobject.cpp
@@ -20,9 +20,9 @@
#include <utility>
#include "gsl/gsl"
+#include "src/buildtool/common/artifact_digest.hpp"
#include "src/buildtool/common/bazel_types.hpp"
#include "src/buildtool/common/protocol_traits.hpp"
-#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp"
#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/execution_api/common/tree_reader_utils.hpp"
@@ -87,14 +87,11 @@ auto RetrieveSubPathId(Artifact::ObjectInfo object_info,
object_info = *new_object_info;
}
else {
- auto const hash = HashFunction{HashFunction::Type::GitSHA1}
- .HashTreeData(*data)
- .Bytes();
auto entries = GitRepo::ReadTreeData(
*data,
- hash,
+ object_info.digest.hash(),
[](auto const& /*unused*/) { return true; },
- /*is_hex_id=*/false);
+ /*is_hex_id=*/true);
if (not entries) {
Logger::Log(LogLevel::Warning,
"Failed to parse tree {} at path '{}'",