[gparted] Pass constant string by reference to lvm2_pv_size_to_num()
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Pass constant string by reference to lvm2_pv_size_to_num()
- Date: Wed, 10 Mar 2021 17:05:25 +0000 (UTC)
commit a41e8b03eca3c0dee750af0206ec18e332c74418
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Sat Mar 6 14:05:59 2021 +0000
Pass constant string by reference to lvm2_pv_size_to_num()
It is common C++ practice to pass a constant object by reference to
avoid constructing a duplicate object for pass by value [1].
[1] How to pass objects to functions in C++?
https://stackoverflow.com/questions/2139224/how-to-pass-objects-to-functions-in-c/2139254#2139254
include/LVM2_PV_Info.h | 2 +-
src/LVM2_PV_Info.cc | 7 ++++---
2 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/include/LVM2_PV_Info.h b/include/LVM2_PV_Info.h
index c87b7b0c..9a00c8ba 100644
--- a/include/LVM2_PV_Info.h
+++ b/include/LVM2_PV_Info.h
@@ -69,7 +69,7 @@ private:
static void load_lvm2_pv_info_cache();
static const LVM2_PV & get_pv_cache_entry_by_name( const Glib::ustring & pvname );
static const LVM2_VG & get_vg_cache_entry_by_name( const Glib::ustring & vgname );
- static Byte_Value lvm2_pv_size_to_num( const Glib::ustring str ) ;
+ static Byte_Value lvm2_pv_size_to_num(const Glib::ustring& str);
static bool bit_set( const Glib::ustring & attr, unsigned int bit ) ;
static bool lvm2_pv_info_cache_initialized ;
static bool lvm_found ;
diff --git a/src/LVM2_PV_Info.cc b/src/LVM2_PV_Info.cc
index 9dfb1ee9..5ae9d993 100644
--- a/src/LVM2_PV_Info.cc
+++ b/src/LVM2_PV_Info.cc
@@ -358,9 +358,10 @@ const LVM2_VG & LVM2_PV_Info::get_vg_cache_entry_by_name( const Glib::ustring &
return vg;
}
-//Return string converted to a number, or -1 for error.
-//Used to convert PVs size or free bytes.
-Byte_Value LVM2_PV_Info::lvm2_pv_size_to_num( const Glib::ustring str )
+
+// Return string converted to a number, or -1 for error.
+// Used to convert PVs size or free bytes.
+Byte_Value LVM2_PV_Info::lvm2_pv_size_to_num(const Glib::ustring& str)
{
Byte_Value num = -1 ;
if ( str != "" )
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]