[gparted] Return constant reference from SWRaid_Info::get_uuid() (!94)



commit 0eedfa60301b9a8169a83eca0390fe776afef7e3
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sat Nov 6 14:00:33 2021 +0000

    Return constant reference from SWRaid_Info::get_uuid() (!94)
    
    Since the only use of SWRaid_Info::get_uuid() assign the returned value
    this doesn't actually save any copy construction.  Do it for consistency
    with the other get_*() methods in SWRaid_Info.
    
    Closes !94 - Make more getter methods use return-by-constant-reference

 include/SWRaid_Info.h | 2 +-
 src/SWRaid_Info.cc    | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/include/SWRaid_Info.h b/include/SWRaid_Info.h
index 5433690d..1c37a546 100644
--- a/include/SWRaid_Info.h
+++ b/include/SWRaid_Info.h
@@ -60,7 +60,7 @@ public:
        static bool is_member_active( const Glib::ustring & member_path );
        static FSType get_fstype(const Glib::ustring& member_path);
        static const Glib::ustring& get_array(const Glib::ustring& member_path);
-       static Glib::ustring get_uuid( 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 );
 
 private:
diff --git a/src/SWRaid_Info.cc b/src/SWRaid_Info.cc
index 217e9521..6e1e12c4 100644
--- a/src/SWRaid_Info.cc
+++ b/src/SWRaid_Info.cc
@@ -93,9 +93,10 @@ const Glib::ustring& SWRaid_Info::get_array(const Glib::ustring& member_path)
        return memb.array;
 }
 
+
 // Return array UUID for the specified member, or "" when failed to parse the UUID or
 // there is no such member.
-Glib::ustring SWRaid_Info::get_uuid( const Glib::ustring & member_path )
+const Glib::ustring& SWRaid_Info::get_uuid(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]