[gparted] Return and use constant reference from SWRaid_Info::get_label() (!94)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Return and use constant reference from SWRaid_Info::get_label() (!94)
- Date: Tue, 16 Nov 2021 19:54:14 +0000 (UTC)
commit 29a4fb4504aaca51f94a0c90b8f558b6013a4934
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Sat Nov 6 14:39:03 2021 +0000
Return and use constant reference from SWRaid_Info::get_label() (!94)
Closes !94 - Make more getter methods use return-by-constant-reference
include/SWRaid_Info.h | 2 +-
src/GParted_Core.cc | 2 +-
src/SWRaid_Info.cc | 3 ++-
3 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/include/SWRaid_Info.h b/include/SWRaid_Info.h
index 1c37a546..baadf35e 100644
--- a/include/SWRaid_Info.h
+++ b/include/SWRaid_Info.h
@@ -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();
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index ece68950..b85c0f0a 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -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 );
diff --git a/src/SWRaid_Info.cc b/src/SWRaid_Info.cc
index 6e1e12c4..ac254354 100644
--- a/src/SWRaid_Info.cc
+++ b/src/SWRaid_Info.cc
@@ -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 );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]