[partition] Using std::find_if to search in container for elements according to a condition

main
Caio Carvalho 6 years ago
parent 34e091833d
commit 2c33535ee8

@ -551,26 +551,22 @@ PartitionCoreModule::lvmPVs() const
bool
PartitionCoreModule::hasVGwithThisName( const QString& name ) const
{
for ( DeviceInfo* d : m_deviceInfos )
if ( dynamic_cast<LvmDevice*>(d->device.data()) &&
d->device.data()->name() == name)
return true;
auto condition = [ name ]( DeviceInfo* d ) {
return dynamic_cast<LvmDevice*>(d->device.data()) && d->device.data()->name() == name;
};
return false;
return std::find_if( m_deviceInfos.begin(), m_deviceInfos.end(), condition ) != m_deviceInfos.end();
}
bool
PartitionCoreModule::isInVG( const Partition *partition ) const
{
for ( DeviceInfo* d : m_deviceInfos )
{
LvmDevice* vg = dynamic_cast<LvmDevice*>( d->device.data() );
auto condition = [ partition ]( DeviceInfo* d ) {
LvmDevice* vg = dynamic_cast<LvmDevice*>( d->device.data());
return vg && vg->physicalVolumes().contains( partition );
};
if ( vg && vg->physicalVolumes().contains( partition ))
return true;
}
return false;
return std::find_if( m_deviceInfos.begin(), m_deviceInfos.end(), condition ) != m_deviceInfos.end();
}
void

Loading…
Cancel
Save