about summary refs log tree commit diff
path: root/src/nix-env/nix-env.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-07-11T15·08-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-07-11T15·08-0400
commit58ef4d9a95584fb89ebcf6222fbac6e698aa6b0b (patch)
tree1e01e79b406f59b06397a24b4b86f1c6fa5fc308 /src/nix-env/nix-env.cc
parent667d5f1936616dc829f9f92f8e5d5141ba5285a7 (diff)
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).
Diffstat (limited to 'src/nix-env/nix-env.cc')
-rw-r--r--src/nix-env/nix-env.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index 2fd4246dd297..91b82c0d09e6 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -932,6 +932,7 @@ static void opQuery(Globals & globals,
 
     /* Query which paths have substitutes. */
     SubstitutablePathInfos subs;
+    PathSet validPaths;
     if (printStatus) {
         PathSet paths;
         foreach (vector<DrvInfo>::iterator, i, elems2)
@@ -941,6 +942,7 @@ static void opQuery(Globals & globals,
                 printMsg(lvlTalkative, format("skipping derivation named `%1%' which gives an assertion failure") % i->name);
                 i->setFailed();
             }
+        validPaths = store->queryValidPaths(paths);
         store->querySubstitutablePathInfos(paths, subs);
     }
 
@@ -966,9 +968,10 @@ static void opQuery(Globals & globals,
             XMLAttrs attrs;
 
             if (printStatus) {
-                bool hasSubs = subs.find(i->queryOutPath(globals.state)) != subs.end();
-                bool isInstalled = installed.find(i->queryOutPath(globals.state)) != installed.end();
-                bool isValid = store->isValidPath(i->queryOutPath(globals.state));
+                Path outPath = i->queryOutPath(globals.state);
+                bool hasSubs = subs.find(outPath) != subs.end();
+                bool isInstalled = installed.find(outPath) != installed.end();
+                bool isValid = validPaths.find(outPath) != validPaths.end();
                 if (xmlOutput) {
                     attrs["installed"] = isInstalled ? "1" : "0";
                     attrs["valid"] = isValid ? "1" : "0";