Return and use constant reference from Partition::get_mountpoint() (!94)

Closes !94 - Make more getter methods use return-by-constant-reference
This commit is contained in:
Mike Fleetwood 2021-11-02 20:13:52 +00:00 committed by Curtis Gedak
parent c8f640655c
commit b3f1c22860
3 changed files with 7 additions and 5 deletions

View File

@ -113,7 +113,7 @@ public:
const Glib::ustring& get_path() const;
void add_mountpoint( const Glib::ustring & mountpoint );
void add_mountpoints( const std::vector<Glib::ustring> & mountpoints );
Glib::ustring get_mountpoint() const ;
const Glib::ustring& get_mountpoint() const;
void clear_mountpoints() ;
std::vector<Glib::ustring> get_mountpoints() const ;
Sector get_sector() const ;

View File

@ -264,7 +264,7 @@ void Dialog_Rescue_Data::check_overlaps(int nPart)
for(unsigned int i=0;i<this->overlappedPartitions.size(); i++)
{
const Glib::ustring& ovrDevPath = this->device->partitions[i].get_path();
Glib::ustring ovrDevMountPoint=this->device->partitions[i].get_mountpoint();
const Glib::ustring& ovrDevMountPoint = this->device->partitions[i].get_mountpoint();
sec_text+="\n"+ovrDevPath+" mounted on "+ovrDevMountPoint;
}
@ -275,7 +275,7 @@ void Dialog_Rescue_Data::check_overlaps(int nPart)
{
for(unsigned int i=0;i<this->overlappedPartitions.size(); i++)
{
Glib::ustring mountP=this->device->partitions[i].get_mountpoint();
const Glib::ustring& mountP=this->device->partitions[i].get_mountpoint();
Glib::ustring commandUmount = "umount " + Glib::shell_quote(mountP);
Utils::execute_command(commandUmount);

View File

@ -364,12 +364,14 @@ void Partition::add_mountpoints( const std::vector<Glib::ustring> & mountpoints
this ->mountpoints .insert( this ->mountpoints .end(), mountpoints .begin(), mountpoints .end() ) ;
}
Glib::ustring Partition::get_mountpoint() const
const Glib::ustring& Partition::get_mountpoint() const
{
if ( mountpoints .size() > 0 )
return mountpoints .front() ;
return "" ;
static Glib::ustring unknown_mountpoint;
return unknown_mountpoint;
}
std::vector<Glib::ustring> Partition::get_mountpoints() const