1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-12 13:36:02 +01:00

refactor(libstore/find-cycles): remove unused hashPathMap parameter

The `hashPathMap` was being passed to `CycleEdgeScanSink` and stored as
a member variable, but was never actually used. The sink only needs the
hash strings for detection via `RefScanSink`, not the full `StorePath`
mapping.
This commit is contained in:
Bernardo Meurer Costa 2025-10-11 19:34:58 +00:00
parent 5803daa940
commit 5eebcf46fe
No known key found for this signature in database
2 changed files with 5 additions and 12 deletions

View file

@ -15,10 +15,8 @@ namespace nix {
// Hash length in characters (32 for base32-encoded sha256) // Hash length in characters (32 for base32-encoded sha256)
static constexpr size_t refLength = StorePath::HashLen; static constexpr size_t refLength = StorePath::HashLen;
CycleEdgeScanSink::CycleEdgeScanSink( CycleEdgeScanSink::CycleEdgeScanSink(StringSet && hashes, std::string storeDir)
StringSet && hashes, std::map<std::string, StorePath> && backMap, std::string storeDir)
: RefScanSink(std::move(hashes)) : RefScanSink(std::move(hashes))
, hashPathMap(std::move(backMap))
, storeDir(std::move(storeDir)) , storeDir(std::move(storeDir))
{ {
} }
@ -62,7 +60,6 @@ StoreCycleEdgeVec && CycleEdgeScanSink::getEdges()
void scanForCycleEdges(const Path & path, const StorePathSet & refs, StoreCycleEdgeVec & edges) void scanForCycleEdges(const Path & path, const StorePathSet & refs, StoreCycleEdgeVec & edges)
{ {
StringSet hashes; StringSet hashes;
std::map<std::string, StorePath> hashPathMap;
// Extract the store directory from the path // Extract the store directory from the path
// Example: /run/user/1000/nix-test/store/abc-foo -> /run/user/1000/nix-test/store/ // Example: /run/user/1000/nix-test/store/abc-foo -> /run/user/1000/nix-test/store/
@ -73,16 +70,13 @@ void scanForCycleEdges(const Path & path, const StorePathSet & refs, StoreCycleE
debug("scanForCycleEdges: storePrefixPath = %s", storePrefixPath.string()); debug("scanForCycleEdges: storePrefixPath = %s", storePrefixPath.string());
debug("scanForCycleEdges: storePrefix = %s", storePrefix); debug("scanForCycleEdges: storePrefix = %s", storePrefix);
// Build map of hash -> StorePath and collect hashes to search for // Collect hashes to search for
for (auto & i : refs) { for (auto & i : refs) {
std::string hashPart(i.hashPart()); hashes.insert(std::string(i.hashPart()));
auto inserted = hashPathMap.emplace(hashPart, i).second;
assert(inserted);
hashes.insert(hashPart);
} }
// Create sink that reuses RefScanSink's hash-finding logic // Create sink that reuses RefScanSink's hash-finding logic
CycleEdgeScanSink sink(std::move(hashes), std::move(hashPathMap), storePrefix); CycleEdgeScanSink sink(std::move(hashes), storePrefix);
// Walk the filesystem and scan files using the sink // Walk the filesystem and scan files using the sink
scanForCycleEdges2(path, sink); scanForCycleEdges2(path, sink);

View file

@ -35,7 +35,6 @@ typedef std::vector<StoreCycleEdge> StoreCycleEdgeVec;
class CycleEdgeScanSink : public RefScanSink class CycleEdgeScanSink : public RefScanSink
{ {
std::string currentFilePath; std::string currentFilePath;
std::map<std::string, StorePath> hashPathMap;
std::string storeDir; std::string storeDir;
// Track hashes we've already recorded for current file // Track hashes we've already recorded for current file
@ -45,7 +44,7 @@ class CycleEdgeScanSink : public RefScanSink
public: public:
StoreCycleEdgeVec edges; StoreCycleEdgeVec edges;
CycleEdgeScanSink(StringSet && hashes, std::map<std::string, StorePath> && backMap, std::string storeDir); CycleEdgeScanSink(StringSet && hashes, std::string storeDir);
/** /**
* Set the current file path being scanned. * Set the current file path being scanned.