Part: use empty() and isEmpty() instead of count() where possible

This commit is contained in:
Benjamin Nauck
2025-03-12 16:01:14 +01:00
parent 51f73c05c0
commit 87f355105e
4 changed files with 9 additions and 4 deletions

View File

@@ -151,6 +151,10 @@ int TopoShapeCache::Ancestry::count() const
return shapes.Extent();
}
bool TopoShapeCache::Ancestry::empty() const
{
return shapes.IsEmpty();
}
TopoShapeCache::TopoShapeCache(const TopoDS_Shape& tds)
: shape(tds.Located(TopLoc_Location()))

View File

@@ -114,6 +114,7 @@ public:
int find(const TopoDS_Shape& parent, const TopoDS_Shape& subShape);
TopoDS_Shape find(const TopoDS_Shape& parent, int index);
int count() const;
bool empty() const;
friend TopoShapeCache;
};

View File

@@ -860,7 +860,7 @@ void TopoShape::mapSubElementForShape(const TopoShape& other, const char* op)
for (auto type : types) {
auto& shapeMap = _cache->getAncestry(type);
auto& otherMap = other._cache->getAncestry(type);
if ((shapeMap.count() == 0) || (otherMap.count() == 0)) {
if ((shapeMap.empty()) || (otherMap.empty())) {
continue;
}
@@ -1450,7 +1450,7 @@ TopoShape& TopoShape::makeShapeWithElementMap(const TopoDS_Shape& shape,
continue;
}
auto& otherMap = incomingShape._cache->getAncestry(info.type);
if (otherMap.count() == 0) {
if (otherMap.empty()) {
continue;
}
for (int i = 1; i <= otherMap.count(); i++) {

View File

@@ -952,7 +952,7 @@ void TaskAttacher::updateListOfModes()
//first up, remember currently selected mode.
eMapMode curMode = mmDeactivated;
auto sel = ui->listOfModes->selectedItems();
if (sel.count() > 0)
if (!sel.isEmpty())
curMode = modesInList[ui->listOfModes->row(sel[0])];
//obtain list of available modes:
@@ -1054,7 +1054,7 @@ void TaskAttacher::selectMapMode(eMapMode mmode) {
Attacher::eMapMode TaskAttacher::getActiveMapMode()
{
auto sel = ui->listOfModes->selectedItems();
if (sel.count() > 0)
if (!sel.isEmpty())
return modesInList[ui->listOfModes->row(sel[0])];
else {
if (this->lastSuggestResult.message == SuggestResult::srOK)