aboutsummaryrefslogtreecommitdiff
path: root/src/nix/why-depends.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix/why-depends.cc')
-rw-r--r--src/nix/why-depends.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/nix/why-depends.cc b/src/nix/why-depends.cc
index f9d54e486..a208e0081 100644
--- a/src/nix/why-depends.cc
+++ b/src/nix/why-depends.cc
@@ -76,7 +76,7 @@ struct CmdWhyDepends : SourceExprCommand
auto packagePath = toStorePath(store, Build, package);
auto dependency = parseInstallable(store, _dependency);
auto dependencyPath = toStorePath(store, NoBuild, dependency);
- auto dependencyPathHash = storePathToHash(store->printStorePath(dependencyPath));
+ auto dependencyPathHash = dependencyPath.hashPart();
StorePathSet closure;
store->computeFSClosure({packagePath}, closure, false, false);
@@ -106,16 +106,16 @@ struct CmdWhyDepends : SourceExprCommand
std::map<StorePath, Node> graph;
for (auto & path : closure)
- graph.emplace(path.clone(), Node { .path = path.clone(), .refs = cloneStorePathSet(store->queryPathInfo(path)->references) });
+ graph.emplace(path, Node { .path = path, .refs = store->queryPathInfo(path)->references });
// Transpose the graph.
for (auto & node : graph)
for (auto & ref : node.second.refs)
- graph.find(ref)->second.rrefs.insert(node.first.clone());
+ graph.find(ref)->second.rrefs.insert(node.first);
/* Run Dijkstra's shortest path algorithm to get the distance
of every path in the closure to 'dependency'. */
- graph.emplace(dependencyPath.clone(), Node { .path = dependencyPath.clone(), .dist = 0 });
+ graph.emplace(dependencyPath, Node { .path = dependencyPath, .dist = 0 });
std::priority_queue<Node *> queue;
@@ -175,7 +175,7 @@ struct CmdWhyDepends : SourceExprCommand
auto & node2 = graph.at(ref);
if (node2.dist == inf) continue;
refs.emplace(node2.dist, &node2);
- hashes.insert(storePathToHash(store->printStorePath(node2.path)));
+ hashes.insert(std::string(node2.path.hashPart()));
}
/* For each reference, find the files and symlinks that
@@ -211,7 +211,7 @@ struct CmdWhyDepends : SourceExprCommand
p2,
hilite(filterPrintable(
std::string(contents, pos2, pos - pos2 + hash.size() + margin)),
- pos - pos2, storePathHashLen,
+ pos - pos2, StorePath::HashLen,
getColour(hash))));
}
}
@@ -224,7 +224,7 @@ struct CmdWhyDepends : SourceExprCommand
auto pos = target.find(hash);
if (pos != std::string::npos)
hits[hash].emplace_back(fmt("%s -> %s\n", p2,
- hilite(target, pos, storePathHashLen, getColour(hash))));
+ hilite(target, pos, StorePath::HashLen, getColour(hash))));
}
}
};
@@ -235,7 +235,7 @@ struct CmdWhyDepends : SourceExprCommand
RunPager pager;
for (auto & ref : refs) {
- auto hash = storePathToHash(store->printStorePath(ref.second->path));
+ std::string hash(ref.second->path.hashPart());
bool last = all ? ref == *refs.rbegin() : true;