mirror of
https://github.com/NixOS/nix.git
synced 2025-11-25 03:39:36 +01:00
Do big rename to clean up code
- `PathReferences` -> `References` - `PathReferences<StorePath>` -> `StoreReference` - `references` -> `others` - `hasSelfReference` -> `self` And get rid of silly subclassing
This commit is contained in:
parent
9cfa78e58a
commit
46e942ff9e
16 changed files with 146 additions and 112 deletions
|
|
@ -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);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue