diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index 1ee63c1b5..e06d191b8 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -551,26 +551,22 @@ PartitionCoreModule::lvmPVs() const bool PartitionCoreModule::hasVGwithThisName( const QString& name ) const { - for ( DeviceInfo* d : m_deviceInfos ) - if ( dynamic_cast(d->device.data()) && - d->device.data()->name() == name) - return true; + auto condition = [ name ]( DeviceInfo* d ) { + return dynamic_cast(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( d->device.data() ); + auto condition = [ partition ]( DeviceInfo* d ) { + LvmDevice* vg = dynamic_cast( 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