Return and use constant reference from SWRaid_Info::get_label() (!94)

Closes !94 - Make more getter methods use return-by-constant-reference
This commit is contained in:
Mike Fleetwood 2021-11-06 14:39:03 +00:00 committed by Curtis Gedak
parent 0eedfa6030
commit 29a4fb4504
3 changed files with 4 additions and 3 deletions

View File

@ -61,7 +61,7 @@ public:
static FSType get_fstype(const Glib::ustring& member_path);
static const Glib::ustring& get_array(const Glib::ustring& member_path);
static const Glib::ustring& get_uuid(const Glib::ustring& member_path);
static Glib::ustring get_label( const Glib::ustring & member_path );
static const Glib::ustring& get_label(const Glib::ustring& member_path);
private:
static void initialise_if_required();

View File

@ -1048,7 +1048,7 @@ void GParted_Core::set_partition_label_and_uuid( Partition & partition )
if (partition.fstype == FS_LINUX_SWRAID ||
partition.fstype == FS_ATARAID )
{
Glib::ustring label = SWRaid_Info::get_label( partition_path );
const Glib::ustring& label = SWRaid_Info::get_label(partition_path);
if ( ! label.empty() )
partition.set_filesystem_label( label );

View File

@ -103,11 +103,12 @@ const Glib::ustring& SWRaid_Info::get_uuid(const Glib::ustring& member_path)
return memb.uuid;
}
// Return array label (array name in mdadm terminology) for the specified member, or ""
// when the array has no label or there is no such member.
// (Metadata 0.90 arrays don't have names. Metata 1.x arrays are always named, getting a
// default of hostname ":" array number when not otherwise specified).
Glib::ustring SWRaid_Info::get_label( const Glib::ustring & member_path )
const Glib::ustring& SWRaid_Info::get_label(const Glib::ustring& member_path)
{
initialise_if_required();
const SWRaid_Member & memb = get_cache_entry_by_member( member_path );