[gparted] Return and use constant reference from Partition::get_mountpoints() (!94)



commit a8e8e9fd97cb1abbed2d7998ddb3966b0ad62f51
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sun Oct 31 17:15:10 2021 +0000

    Return and use constant reference from Partition::get_mountpoints() (!94)
    
    Closes !94 - Make more getter methods use return-by-constant-reference

 include/Partition.h    | 2 +-
 src/Partition.cc       | 3 ++-
 src/TreeView_Detail.cc | 2 +-
 src/Win_GParted.cc     | 4 ++--
 4 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/include/Partition.h b/include/Partition.h
index 495843de..f810828d 100644
--- a/include/Partition.h
+++ b/include/Partition.h
@@ -115,7 +115,7 @@ public:
        void add_mountpoints( const std::vector<Glib::ustring> & mountpoints );
        const Glib::ustring& get_mountpoint() const;
        void clear_mountpoints() ;
-       std::vector<Glib::ustring> get_mountpoints() const ;
+       const std::vector<Glib::ustring>& get_mountpoints() const;
        Sector get_sector() const ;
        bool test_overlap( const Partition & partition ) const ;
        bool filesystem_label_known() const;
diff --git a/src/Partition.cc b/src/Partition.cc
index f3a83f9a..c399104c 100644
--- a/src/Partition.cc
+++ b/src/Partition.cc
@@ -374,7 +374,8 @@ const Glib::ustring& Partition::get_mountpoint() const
        return unknown_mountpoint;
 }
 
-std::vector<Glib::ustring> Partition::get_mountpoints() const 
+
+const std::vector<Glib::ustring>& Partition::get_mountpoints() const
 {
        return mountpoints ;
 }
diff --git a/src/TreeView_Detail.cc b/src/TreeView_Detail.cc
index a63cd4eb..4b21f04a 100644
--- a/src/TreeView_Detail.cc
+++ b/src/TreeView_Detail.cc
@@ -191,7 +191,7 @@ void TreeView_Detail::create_row( const Gtk::TreeRow & treerow,
        treerow[treeview_detail_columns.fsname] = partition.get_filesystem_string();
 
        // mount point
-       std::vector<Glib::ustring> temp_mountpoints = filesystem_ptn.get_mountpoints();
+       const std::vector<Glib::ustring>& temp_mountpoints = filesystem_ptn.get_mountpoints();
        treerow[treeview_detail_columns.mountpoint] = Glib::build_path( ", ", temp_mountpoints );
        if ( ! temp_mountpoints.empty() )
                show_mountpoints = true;
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index a820bd25..674f66ad 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -1467,7 +1467,7 @@ void Win_GParted::set_valid_operations()
                        partitionmenu_items[MENU_MOUNT]->unset_submenu();
 
                        Gtk::Menu *menu = manage(new Gtk::Menu());
-                       std::vector<Glib::ustring> temp_mountpoints = selected_filesystem.get_mountpoints();
+                       const std::vector<Glib::ustring>& temp_mountpoints = 
selected_filesystem.get_mountpoints();
                        for ( unsigned int t = 0 ; t < temp_mountpoints.size() ; t++ )
                        {
                                Gtk::MenuItem *item;
@@ -2843,7 +2843,7 @@ void Win_GParted::toggle_crypt_busy_state()
 
 bool Win_GParted::unmount_partition( const Partition & partition, Glib::ustring & error )
 {
-       const std::vector<Glib::ustring> fs_mountpoints = partition.get_mountpoints();
+       const std::vector<Glib::ustring>& fs_mountpoints = partition.get_mountpoints();
        const std::vector<Glib::ustring> all_mountpoints = Mount_Info::get_all_mountpoints();
 
        std::vector<Glib::ustring> skipped_mountpoints;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]