summaryrefslogtreecommitdiff
path: root/src/buildtool/build_engine/expression/configuration.hpp
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2025-01-24 14:29:44 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2025-01-24 17:17:00 +0100
commit8e0c914a68f2d113fbfcfb730b94fe6cdb5e0e0c (patch)
tree5406fee53e3b9634bc1dad21844af7f33a1f5a9b /src/buildtool/build_engine/expression/configuration.hpp
parent95b78e899b1f2c8de39426697f8b9fa0c221d5e9 (diff)
downloadjustbuild-8e0c914a68f2d113fbfcfb730b94fe6cdb5e0e0c.tar.gz
Add native comparison of configured targets
... and use it when normalizing the origins of actions. For this task, any well-defined linear order is sufficient. Using a native comparision (rather than comparing the canonical serialisation) significantly speeds up that normalisation process, as the assumption that it would be rare that an action has more than one origin turned out to be false. In fact, we have seeen cases where this sorting used to take several seconds before this change, so that this change reduced analysis time by more than a factor of 5.
Diffstat (limited to 'src/buildtool/build_engine/expression/configuration.hpp')
-rw-r--r--src/buildtool/build_engine/expression/configuration.hpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/buildtool/build_engine/expression/configuration.hpp b/src/buildtool/build_engine/expression/configuration.hpp
index ec3fde66..dadb71d2 100644
--- a/src/buildtool/build_engine/expression/configuration.hpp
+++ b/src/buildtool/build_engine/expression/configuration.hpp
@@ -16,6 +16,7 @@
#define INCLUDED_SRC_BUILDTOOL_BUILD_ENGINE_EXPRESSION_CONFIGURATION_HPP
#include <algorithm>
+#include <compare>
#include <cstddef>
#include <functional>
#include <optional>
@@ -92,6 +93,10 @@ class Configuration {
return expr_ == other.expr_;
}
+ [[nodiscard]] auto operator<(const Configuration& other) const -> bool {
+ return expr_->ToHash() < other.expr_->ToHash();
+ }
+
[[nodiscard]] auto hash() const noexcept -> std::size_t {
return std::hash<ExpressionPtr>{}(expr_);
}