Modernizing countObjectsOfType functions

This commit is contained in:
Benjamin Nauck
2025-01-11 19:57:53 +01:00
parent 7b22027b90
commit 3ea3ae0132
2 changed files with 6 additions and 15 deletions

View File

@@ -4397,14 +4397,9 @@ Document::findObjects(const Base::Type& typeId, const char* objname, const char*
int Document::countObjectsOfType(const Base::Type& typeId) const
{
int ct = 0;
for (const auto& it : d->objectMap) {
if (it.second->getTypeId().isDerivedFrom(typeId)) {
ct++;
}
}
return ct;
return std::count_if(d->objectMap.begin(), d->objectMap.end(), [&](const auto& it) {
return it.second->getTypeId().isDerivedFrom(typeId);
});
}
int Document::countObjectsOfType(const char* typeName) const