summaryrefslogtreecommitdiff
path: root/src/buildtool/build_engine/expression/expression.cpp
diff options
context:
space:
mode:
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()) {