From e0204f8d462041387651af388074491fd0bf36d6 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 19 Apr 2016 18:50:15 +0200 Subject: Move path info caching from BinaryCacheStore to Store Caching path info is generally useful. For instance, it speeds up "nix path-info -rS /run/current-system" (i.e. showing the closure sizes of all paths in the closure of the current system) from 5.6s to 0.15s. This also eliminates some APIs like Store::queryDeriver() and Store::queryReferences(). --- src/libutil/lru-cache.hh | 6 ++++++ src/libutil/ref.hh | 6 ++++++ 2 files changed, 12 insertions(+) (limited to 'src/libutil') diff --git a/src/libutil/lru-cache.hh b/src/libutil/lru-cache.hh index 4344d6601bc8..35983aa2c918 100644 --- a/src/libutil/lru-cache.hh +++ b/src/libutil/lru-cache.hh @@ -79,6 +79,12 @@ public: { return data.size(); } + + void clear() + { + data.clear(); + lru.clear(); + } }; } diff --git a/src/libutil/ref.hh b/src/libutil/ref.hh index 349f24f7c488..9f5da09152c9 100644 --- a/src/libutil/ref.hh +++ b/src/libutil/ref.hh @@ -43,6 +43,12 @@ public: return p; } + template + ref cast() + { + return ref(std::dynamic_pointer_cast(p)); + } + template operator ref () { -- cgit 1.4.1