Use constant reference from btrfs::get_cache_entry() (!94)

Method already returned a constant reference.  Change local variables to
constant references to avoid copy constructing them.

Closes !94 - Make more getter methods use return-by-constant-reference
This commit is contained in:
Mike Fleetwood 2021-11-02 20:43:35 +00:00 committed by Curtis Gedak
parent a8e8e9fd97
commit 0a4761df46
1 changed files with 4 additions and 3 deletions

View File

@ -285,8 +285,8 @@ bool btrfs::resize( const Partition & partition_new, OperationDetail & operation
{ {
bool success = true ; bool success = true ;
const Glib::ustring& path = partition_new.get_path(); const Glib::ustring& path = partition_new.get_path();
const BTRFS_Device& btrfs_dev = get_cache_entry(path);
BTRFS_Device btrfs_dev = get_cache_entry( path ) ;
if ( btrfs_dev .devid == -1 ) if ( btrfs_dev .devid == -1 )
{ {
operationdetail .add_child( OperationDetail( operationdetail .add_child( OperationDetail(
@ -400,7 +400,8 @@ void btrfs::clear_cache()
// Return empty string if not found (not mounted). // Return empty string if not found (not mounted).
Glib::ustring btrfs::get_mount_device( const Glib::ustring & path ) Glib::ustring btrfs::get_mount_device( const Glib::ustring & path )
{ {
BTRFS_Device btrfs_dev = get_cache_entry( path ) ; const BTRFS_Device& btrfs_dev = get_cache_entry(path);
if ( btrfs_dev .devid == -1 || btrfs_dev .members .empty() ) if ( btrfs_dev .devid == -1 || btrfs_dev .members .empty() )
{ {
//WARNING: //WARNING:
@ -421,7 +422,7 @@ Glib::ustring btrfs::get_mount_device( const Glib::ustring & path )
std::vector<Glib::ustring> btrfs::get_members( const Glib::ustring & path ) std::vector<Glib::ustring> btrfs::get_members( const Glib::ustring & path )
{ {
BTRFS_Device btrfs_dev = get_cache_entry( path ) ; const BTRFS_Device& btrfs_dev = get_cache_entry(path);
std::vector<Glib::ustring> membs; std::vector<Glib::ustring> membs;
for ( unsigned int i = 0 ; i < btrfs_dev.members.size() ; i ++ ) for ( unsigned int i = 0 ; i < btrfs_dev.members.size() ; i ++ )
membs.push_back( btrfs_dev.members[i].m_name ); membs.push_back( btrfs_dev.members[i].m_name );