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
This commit is contained in:
Mike Fleetwood 2021-03-06 14:05:59 +00:00 committed by Curtis Gedak
parent c0a7aa438a
commit a41e8b03ec
2 changed files with 5 additions and 4 deletions

View File

@ -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 ;

View File

@ -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 != "" )