From 4981a97a67a2b8f6f67ab65d548133b996a216b6 Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Mon, 8 Apr 2024 12:23:09 +0800 Subject: [PATCH] libnixt: hack eval cache instead of parse cache (#384) --- libnixt/include/nixt/HackCache.h | 20 ++++++++++---------- nixd/nix-node-eval/src/EvalProvider.cpp | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libnixt/include/nixt/HackCache.h b/libnixt/include/nixt/HackCache.h index 4b0ba36d5..f52992561 100644 --- a/libnixt/include/nixt/HackCache.h +++ b/libnixt/include/nixt/HackCache.h @@ -1,4 +1,4 @@ -/// Access ParseCache in \p nix::EvalState +/// Access EvalCache in \p nix::EvalState #pragma once @@ -7,11 +7,11 @@ namespace nixt { #if HAVE_BOEHMGC -using FileParseCache = std::map< - nix::SourcePath, nix::Expr *, std::less, - traceable_allocator>>; +using FileEvalCache = + std::map, + traceable_allocator>>; #else -using FileParseCache = std::map; +using FileEvalCache = std::map; #endif namespace detail { @@ -35,16 +35,16 @@ typename RB::F RB::FO; // Impl -struct ParseCacheF { - using type = FileParseCache nix::EvalState::*; +struct EvalCacheF { + using type = FileEvalCache nix::EvalState::*; }; -template struct RB; +template struct RB; } // namespace detail -inline FileParseCache &getFileParseCache(nix::EvalState &S) { - return S.*detail::R::P; +inline FileEvalCache &getFileEvalCache(nix::EvalState &S) { + return S.*detail::R::P; } } // namespace nixt diff --git a/nixd/nix-node-eval/src/EvalProvider.cpp b/nixd/nix-node-eval/src/EvalProvider.cpp index ed9b865be..ee2717138 100644 --- a/nixd/nix-node-eval/src/EvalProvider.cpp +++ b/nixd/nix-node-eval/src/EvalProvider.cpp @@ -63,8 +63,8 @@ void EvalProvider::onRegisterBC(const rpc::RegisterBCParams &Params) { State->eval(AST, V); // Inject pre-parsed AST into EvalState cache - auto Cache = nixt::getFileParseCache(*State); - Cache[CachePath] = AST; + auto &Cache = nixt::getFileEvalCache(*State); + Cache[CachePath] = V; } void EvalProvider::onExprValue(const ExprValueParams &Params,