From 58ef4d9a95584fb89ebcf6222fbac6e698aa6b0b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 11 Jul 2012 11:08:47 -0400 Subject: Add a function queryValidPaths() queryValidPaths() combines multiple calls to isValidPath() in one. This matters when using the Nix daemon because it reduces latency. For instance, on "nix-env -qas \*" it reduces execution time from 5.7s to 4.7s (which is indistinguishable from the non-daemon case). --- src/libstore/remote-store.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/libstore/remote-store.cc') diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 04a9e28c9007..0cd29c5751d2 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -217,6 +217,23 @@ bool RemoteStore::isValidPath(const Path & path) } +PathSet RemoteStore::queryValidPaths(const PathSet & paths) +{ + if (GET_PROTOCOL_MINOR(daemonVersion) < 12) { + PathSet res; + foreach (PathSet::const_iterator, i, paths) + if (isValidPath(*i)) res.insert(*i); + return res; + } else { + openConnection(); + writeInt(wopQueryValidPaths, to); + writeStrings(paths, to); + processStderr(); + return readStorePaths(from); + } +} + + PathSet RemoteStore::queryAllValidPaths() { openConnection(); -- cgit 1.4.1