packagefs: Rename operator< to HasPrecendenceOver().

As suggested by weinhold on the mailing list.
This commit is contained in:
Augustin Cavalier 2018-08-08 23:41:37 -04:00
parent f6ff5a9790
commit d8ad2d6f33
6 changed files with 23 additions and 23 deletions

View File

@ -108,7 +108,8 @@ UnpackingDirectory::AddPackageNode(PackageNode* packageNode, dev_t deviceID)
= dynamic_cast<PackageDirectory*>(packageNode);
PackageDirectory* other = fPackageDirectories.Head();
bool overridesHead = other == NULL || *packageDirectory > *other;
bool overridesHead = other == NULL
|| packageDirectory->HasPrecedenceOver(other);
if (overridesHead) {
fPackageDirectories.Insert(other, packageDirectory);
@ -134,7 +135,7 @@ UnpackingDirectory::RemovePackageNode(PackageNode* packageNode, dev_t deviceID)
it.Next();
// skip the first one
while (PackageDirectory* otherNode = it.Next()) {
if (*otherNode > *newestNode)
if (otherNode->HasPrecedenceOver(newestNode))
newestNode = otherNode;
}
@ -169,7 +170,7 @@ UnpackingDirectory::WillBeFirstPackageNode(PackageNode* packageNode) const
return false;
PackageDirectory* other = fPackageDirectories.Head();
return other == NULL || *packageDirectory > *other;
return other == NULL || packageDirectory->HasPrecedenceOver(other);
}

View File

@ -116,7 +116,8 @@ UnpackingLeafNode::AddPackageNode(PackageNode* packageNode, dev_t deviceID)
= dynamic_cast<PackageLeafNode*>(packageNode);
PackageLeafNode* headNode = fPackageNodes.Head();
bool overridesHead = headNode == NULL || *packageLeafNode > *headNode;
bool overridesHead = headNode == NULL
|| packageLeafNode->HasPrecedenceOver(headNode);
if (overridesHead) {
fPackageNodes.Add(packageLeafNode);
@ -148,7 +149,7 @@ UnpackingLeafNode::RemovePackageNode(PackageNode* packageNode, dev_t deviceID)
it.Next();
// skip the first one
while (PackageLeafNode* otherNode = it.Next()) {
if (*otherNode > *newestNode)
if (otherNode->HasPrecedenceOver(newestNode))
newestNode = otherNode;
}
@ -186,7 +187,8 @@ UnpackingLeafNode::WillBeFirstPackageNode(PackageNode* packageNode) const
return false;
PackageLeafNode* headNode = fPackageNodes.Head();
return headNode == NULL || *packageLeafNode > *headNode;
return headNode == NULL
|| packageLeafNode->ModifiedTime() > headNode->ModifiedTime();
}
void

View File

@ -39,19 +39,19 @@ PackageDirectory::RemoveChild(PackageNode* node)
bool
PackageDirectory::operator<(const PackageDirectory& other) const
PackageDirectory::HasPrecedenceOver(const PackageDirectory* other) const
{
// If one of us has the SYSTEM_PACKAGE flag and the other doesn't,
// let PackageNode take care of the comparison.
if ((fPackageFlags & BPackageKit::B_PACKAGE_FLAG_SYSTEM_PACKAGE)
!= (other.fPackageFlags
!= (other->fPackageFlags
& BPackageKit::B_PACKAGE_FLAG_SYSTEM_PACKAGE)) {
return PackageNode::operator<(other);
return PackageNode::HasPrecedenceOver(other);
}
const int32 attrs = fAttributes.Count(),
otherAttrs = other.fAttributes.Count();
otherAttrs = other->fAttributes.Count();
if (attrs != otherAttrs)
return attrs < otherAttrs;
return PackageNode::operator<(other);
return attrs > otherAttrs;
return PackageNode::HasPrecedenceOver(other);
}

View File

@ -26,9 +26,8 @@ public:
const PackageNodeList& Children() const
{ return fChildren; }
bool operator<(const PackageDirectory& other) const;
inline bool operator>(const PackageDirectory& other) const
{ return other < *this; }
bool HasPrecedenceOver(const PackageDirectory* other)
const;
private:
PackageNodeList fChildren;

View File

@ -106,15 +106,15 @@ PackageNode::UnsetIndexCookie(void* attributeCookie)
bool
PackageNode::operator<(const PackageNode& other) const
PackageNode::HasPrecedenceOver(const PackageNode* other) const
{
const bool isSystemPkg = (fPackageFlags
& BPackageKit::B_PACKAGE_FLAG_SYSTEM_PACKAGE) != 0,
otherIsSystemPkg = (other.fPackageFlags
otherIsSystemPkg = (other->fPackageFlags
& BPackageKit::B_PACKAGE_FLAG_SYSTEM_PACKAGE) != 0;
if (isSystemPkg && !otherIsSystemPkg)
return false;
if (!isSystemPkg && otherIsSystemPkg)
return true;
return fModifiedTime < other.fModifiedTime;
if (!isSystemPkg && otherIsSystemPkg)
return false;
return fModifiedTime > other->fModifiedTime;
}

View File

@ -73,9 +73,7 @@ public:
inline void* IndexCookieForAttribute(const StringKey& name)
const;
bool operator<(const PackageNode& other) const;
inline bool operator>(const PackageNode& other) const
{ return other < *this; }
bool HasPrecedenceOver(const PackageNode* other) const;
// conceptually protected, but actually declaring it so causes
// compilation issues when used with MethodDeleter in subclasses