[gparted] Sort command line named disk devices and remove duplicates (#755495)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Sort command line named disk devices and remove duplicates (#755495)
- Date: Fri, 9 Oct 2015 16:08:03 +0000 (UTC)
commit 3d3d98994bd1b3fc56260b65e576cf0f8d6a50ea
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Tue Oct 6 18:50:42 2015 +0100
Sort command line named disk devices and remove duplicates (#755495)
Order named disk devices so that they appear in the combo box in the
same order which they would when probed. Also remove duplicates so that
the same disk devices aren't scanned multiple times and appear
duplicated in the UI.
Try this; it used to take ages to load and looked weird:
# gparted /dev/sda /dev/sdb /dev/sda /dev/sdb /dev/sda /dev/sdb
Bug 755495 - GParted allowing partitioning of large sector devices
specified on the command line, when built with old
libparted which doesn't support it
src/GParted_Core.cc | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 7c91f6a..6e06077 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -229,6 +229,14 @@ void GParted_Core::set_devices_thread( std::vector<Device> * pdevices )
{
//Device paths were passed in on the command line.
+ // Sort name device paths and remove duplicates. Avoids repeated scanning
+ // the same device and showing it multiple times in the UI.
+ // Reference:
+ // What's the most efficient way to erase duplicates and sort a vector?
+ //
http://stackoverflow.com/questions/1041620/whats-the-most-efficient-way-to-erase-duplicates-and-sort-a-vector
+ std::sort( device_paths.begin(), device_paths.end() );
+ device_paths.erase( std::unique( device_paths.begin(), device_paths.end() ),
device_paths.end() );
+
for ( unsigned int t = 0 ; t < device_paths .size() ; t++ )
{
set_thread_status_message( String::ucompose( _("Confirming %1"), device_paths[t] ) );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]