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

Closes !94 - Make more getter methods use return-by-constant-reference
This commit is contained in:
Mike Fleetwood 2021-11-02 20:03:08 +00:00 committed by Curtis Gedak
parent 301690d9ff
commit c8f640655c
4 changed files with 9 additions and 5 deletions

View File

@ -119,7 +119,7 @@ public:
Sector get_sector() const ; Sector get_sector() const ;
bool test_overlap( const Partition & partition ) const ; bool test_overlap( const Partition & partition ) const ;
bool filesystem_label_known() const; bool filesystem_label_known() const;
Glib::ustring get_filesystem_label() const; const Glib::ustring& get_filesystem_label() const;
void set_filesystem_label( const Glib::ustring & filesystem_label ); void set_filesystem_label( const Glib::ustring & filesystem_label );
// Message accessors. Messages are stored locally and accessed globally. // Message accessors. Messages are stored locally and accessed globally.

View File

@ -271,14 +271,18 @@ bool Partition::filesystem_label_known() const
return have_filesystem_label; return have_filesystem_label;
} }
//Return the file system label or "" if unknown. //Return the file system label or "" if unknown.
Glib::ustring Partition::get_filesystem_label() const const Glib::ustring& Partition::get_filesystem_label() const
{ {
if ( have_filesystem_label ) if ( have_filesystem_label )
return filesystem_label; return filesystem_label;
return "";
static Glib::ustring unknown_label;
return unknown_label;
} }
void Partition::set_filesystem_label( const Glib::ustring & filesystem_label ) void Partition::set_filesystem_label( const Glib::ustring & filesystem_label )
{ {
this->filesystem_label = filesystem_label; this->filesystem_label = filesystem_label;

View File

@ -197,7 +197,7 @@ void TreeView_Detail::create_row( const Gtk::TreeRow & treerow,
show_mountpoints = true; show_mountpoints = true;
//label //label
Glib::ustring temp_filesystem_label = filesystem_ptn.get_filesystem_label(); const Glib::ustring& temp_filesystem_label = filesystem_ptn.get_filesystem_label();
treerow[treeview_detail_columns.label] = temp_filesystem_label; treerow[treeview_detail_columns.label] = temp_filesystem_label;
if ( ! temp_filesystem_label.empty() ) if ( ! temp_filesystem_label.empty() )
show_labels = true; show_labels = true;

View File

@ -200,7 +200,7 @@ bool udf::create( const Partition & new_partition, OperationDetail & operationde
Glib::ustring label_args; Glib::ustring label_args;
if ( ! new_partition.get_filesystem_label().empty() ) if ( ! new_partition.get_filesystem_label().empty() )
{ {
const Glib::ustring label = new_partition.get_filesystem_label(); const Glib::ustring& label = new_partition.get_filesystem_label();
// Mkudffs from udftools prior to version 1.1 damages the label if it // Mkudffs from udftools prior to version 1.1 damages the label if it
// contains non-ASCII characters. Therefore do not allow a label with // contains non-ASCII characters. Therefore do not allow a label with