From 18a1f459db85dae0eb2d7b46fd98422eda3952f0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 12 Jul 2017 05:54:22 -0400 Subject: [PATCH] Partition: reduce code duplications --- src/modules/partition/core/DeviceList.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modules/partition/core/DeviceList.cpp b/src/modules/partition/core/DeviceList.cpp index f9125f4de..207306ac4 100644 --- a/src/modules/partition/core/DeviceList.cpp +++ b/src/modules/partition/core/DeviceList.cpp @@ -98,6 +98,13 @@ isIso9660( const Device* device ) } +static inline QDebug& +operator <<( QDebug& s, QList< Device* >::iterator& it ) +{ + s << ( ( *it ) ? ( *it )->deviceNode() : QString( "" ) ); + return s; +} + QList< Device* > getDevices( DeviceType which ) { bool writableOnly = (which == DeviceType::WritableOnly); @@ -115,7 +122,7 @@ QList< Device* > getDevices( DeviceType which ) ( *it )->deviceNode().startsWith( "/dev/zram" ) ) { - cDebug() << " .. Removing" << ( ( *it ) ? ( *it )->deviceNode() : QString( "" ) ); + cDebug() << " .. Removing" << it; it = devices.erase( it ); } @@ -125,7 +132,7 @@ QList< Device* > getDevices( DeviceType which ) isMounted( *it ) ) ) { - cDebug() << " .. Removing" << ( ( *it ) ? ( *it )->deviceNode() : QString( "" ) ); + cDebug() << " .. Removing" << it; it = devices.erase( it ); } else