From d9e35f9d82acbc661aca0cb5608e052434e52dc8 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Wed, 15 Jun 2022 15:45:24 +0200 Subject: expression: cache the cacheability property --- src/buildtool/build_engine/expression/expression.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/buildtool/build_engine/expression/expression.cpp') 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; @@ -152,6 +152,11 @@ auto Expression::ToHash() const noexcept -> std::string { return hash_.SetOnceAndGet([this] { return ComputeHash(); }); } +// 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 { -- cgit v1.2.3