about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-19T16·50+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-19T16·52+0200
commite0204f8d462041387651af388074491fd0bf36d6 (patch)
treeecd20759ce49499722d140d653c5678051bcdfc2 /src/libutil
parent608b0265e104b4a97f51e5745b1a32078770f3cf (diff)
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().
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/lru-cache.hh6
-rw-r--r--src/libutil/ref.hh6
2 files changed, 12 insertions, 0 deletions
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
@@ -44,6 +44,12 @@ public:
     }
 
     template<typename T2>
+    ref<T2> cast()
+    {
+        return ref<T2>(std::dynamic_pointer_cast<T2>(p));
+    }
+
+    template<typename T2>
     operator ref<T2> ()
     {
         return ref<T2>((std::shared_ptr<T2>) p);