[gparted] Stop unnecessarily coping a Partition in Dialog_Rescue_Data (#759726)



commit 9f4e6909c59ac8a767ca8c74f6a62cb9f9b39a7d
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sun Dec 13 13:39:01 2015 +0000

    Stop unnecessarily coping a Partition in Dialog_Rescue_Data (#759726)
    
    The code in on_view_clicked() copy constructed a Partition object and
    then in the following 3 lines only read a couple of public member
    variables from the new copy.
    
    Making a copy of the partition is unnecessary.  Change to just creating
    a constant reference to the Partition instead.
    
    (It would also be an impediment to polymorphically using Partition
    objects, except for the fact that gpart doesn't recognise LUKS
    signatures so will never have to create a PartitionLUKS object).
    
    Bug 759726 - Implement Partition object polymorphism

 src/Dialog_Rescue_Data.cc |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/src/Dialog_Rescue_Data.cc b/src/Dialog_Rescue_Data.cc
index a8ab6fc..da87a55 100644
--- a/src/Dialog_Rescue_Data.cc
+++ b/src/Dialog_Rescue_Data.cc
@@ -151,7 +151,7 @@ void Dialog_Rescue_Data::create_list_of_fs()
  * Callback function for "View" button */
 void Dialog_Rescue_Data::on_view_clicked(int nPart)
 {
-       Partition part=this->partitions[nPart];
+       const Partition & part = this->partitions[nPart];
 
        Byte_Value initOffset=this->sector_size*part.sector_start;
        Sector numSectors=part.sector_end-part.sector_start+1;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]