summaryrefslogtreecommitdiff
path: root/src/buildtool/build_engine/expression/expression.cpp
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2022-06-15 15:45:24 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2022-06-20 16:54:03 +0200
commitd9e35f9d82acbc661aca0cb5608e052434e52dc8 (patch)
tree6f375e33245314f176c5fb007a8ec492df727410 /src/buildtool/build_engine/expression/expression.cpp
parent74dc83943b6100551afc3b66fa21ac7b16175f13 (diff)
downloadjustbuild-d9e35f9d82acbc661aca0cb5608e052434e52dc8.tar.gz
expression: cache the cacheability property
Diffstat (limited to 'src/buildtool/build_engine/expression/expression.cpp')
-rw-r--r--src/buildtool/build_engine/expression/expression.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/buildtool/build_engine/expression/expression.cpp b/src/buildtool/build_engine/expression/expression.cpp
index 6ae9bd87..6891d7ab 100644
--- a/src/buildtool/build_engine/expression/expression.cpp
+++ b/src/buildtool/build_engine/expression/expression.cpp
@@ -114,7 +114,7 @@ auto Expression::ToJson(Expression::JsonMode mode) const -> nlohmann::json {
}
// NOLINTNEXTLINE(misc-no-recursion)
-auto Expression::IsCacheable() const -> bool {
+auto Expression::ComputeIsCacheable() const -> bool {
// Must be updated whenever we add a new non-cacheable value
if (IsName()) {
return false;
@@ -153,6 +153,11 @@ auto Expression::ToHash() const noexcept -> std::string {
}
// NOLINTNEXTLINE(misc-no-recursion)
+auto Expression::IsCacheable() const -> bool {
+ return is_cachable_.SetOnceAndGet([this] { return ComputeIsCacheable(); });
+}
+
+// NOLINTNEXTLINE(misc-no-recursion)
auto Expression::FromJson(nlohmann::json const& json) noexcept
-> ExpressionPtr {
if (json.is_null()) {