[gparted] Use constant reference from btrfs::get_cache_entry() (!94)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Use constant reference from btrfs::get_cache_entry() (!94)
- Date: Tue, 16 Nov 2021 19:54:14 +0000 (UTC)
commit 0a4761df46364e050d8d6426b2c067f800be535e
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Tue Nov 2 20:43:35 2021 +0000
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
src/btrfs.cc | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/src/btrfs.cc b/src/btrfs.cc
index 8d66fedf..b465908a 100644
--- a/src/btrfs.cc
+++ b/src/btrfs.cc
@@ -285,8 +285,8 @@ bool btrfs::resize( const Partition & partition_new, OperationDetail & operation
{
bool success = true ;
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 )
{
operationdetail .add_child( OperationDetail(
@@ -400,7 +400,8 @@ void btrfs::clear_cache()
// Return empty string if not found (not mounted).
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() )
{
//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 )
{
- BTRFS_Device btrfs_dev = get_cache_entry( path ) ;
+ const BTRFS_Device& btrfs_dev = get_cache_entry(path);
std::vector<Glib::ustring> membs;
for ( unsigned int i = 0 ; i < btrfs_dev.members.size() ; i ++ )
membs.push_back( btrfs_dev.members[i].m_name );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]