aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/content-address.hh
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-01-06 15:36:05 -0500
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-01-06 15:36:05 -0500
commit46e942ff9e65755689ee72f93846d7118e1b8d45 (patch)
tree81c51237516835c37cb21407a391c905c16b5c08 /src/libstore/content-address.hh
parent9cfa78e58a92b4bf034867bc1296a200bdc3f12a (diff)
Do big rename to clean up code
- `PathReferences` -> `References` - `PathReferences<StorePath>` -> `StoreReference` - `references` -> `others` - `hasSelfReference` -> `self` And get rid of silly subclassing
Diffstat (limited to 'src/libstore/content-address.hh')
-rw-r--r--src/libstore/content-address.hh46
1 files changed, 3 insertions, 43 deletions
diff --git a/src/libstore/content-address.hh b/src/libstore/content-address.hh
index 6be4be4c5..f8a4d5370 100644
--- a/src/libstore/content-address.hh
+++ b/src/libstore/content-address.hh
@@ -4,6 +4,7 @@
#include "hash.hh"
#include "path.hh"
#include "comparator.hh"
+#include "reference-set.hh"
namespace nix {
@@ -94,48 +95,7 @@ Hash getContentAddressHash(const ContentAddress & ca);
* References set
*/
-template<typename Ref>
-struct PathReferences
-{
- std::set<Ref> references;
- bool hasSelfReference = false;
-
- /* Functions to view references + hasSelfReference as one set, mainly for
- compatibility's sake. */
- StorePathSet referencesPossiblyToSelf(const Ref & self) const;
- void insertReferencePossiblyToSelf(const Ref & self, Ref && ref);
- void setReferencesPossiblyToSelf(const Ref & self, std::set<Ref> && refs);
-
- GENERATE_CMP(PathReferences<Ref>, me->references, me->hasSelfReference);
-};
-
-template<typename Ref>
-StorePathSet PathReferences<Ref>::referencesPossiblyToSelf(const Ref & self) const
-{
- StorePathSet refs { references };
- if (hasSelfReference)
- refs.insert(self);
- return refs;
-}
-
-template<typename Ref>
-void PathReferences<Ref>::insertReferencePossiblyToSelf(const Ref & self, Ref && ref)
-{
- if (ref == self)
- hasSelfReference = true;
- else
- references.insert(std::move(ref));
-}
-
-template<typename Ref>
-void PathReferences<Ref>::setReferencesPossiblyToSelf(const Ref & self, std::set<Ref> && refs)
-{
- if (refs.count(self))
- hasSelfReference = true;
- refs.erase(self);
-
- references = refs;
-}
+typedef References<StorePath> StoreReferences;
/*
* Full content address
@@ -153,7 +113,7 @@ struct TextInfo : TextHash {
struct FixedOutputInfo : FixedOutputHash {
// References for the paths
- PathReferences<StorePath> references;
+ StoreReferences references;
GENERATE_CMP(FixedOutputInfo, *(const FixedOutputHash *)me, me->references);
};