aboutsummaryrefslogtreecommitdiff
path: root/src/nix/why-depends.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-06-16 14:16:39 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-06-16 14:28:41 +0200
commit759947bf72c134592f0ce23d385e48095bd0a301 (patch)
tree98868cbafb2baa1d369cf2a1464e9fa4805ab3a7 /src/nix/why-depends.cc
parent72e17290d457a8e911f126d21b74c315b034189d (diff)
StorePath: Rewrite in C++
On nix-env -qa -f '<nixpkgs>', this reduces maximum RSS by 20970 KiB and runtime by 0.8%. This is mostly because we're not parsing the hash part as a hash anymore (just validating that it consists of base-32 characters). Also, replace storePathToHash() by StorePath::hashPart().
Diffstat (limited to 'src/nix/why-depends.cc')
-rw-r--r--src/nix/why-depends.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/nix/why-depends.cc b/src/nix/why-depends.cc
index 6057beedb..a4ee2d971 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(*this, store, _dependency, false);
auto dependencyPath = toStorePath(store, NoBuild, dependency);
- auto dependencyPathHash = storePathToHash(store->printStorePath(dependencyPath));
+ auto dependencyPathHash = dependencyPath.hashPart();
StorePathSet closure;
store->computeFSClosure({packagePath}, closure, false, false);
@@ -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;