Stop copying selected_partition back on itself in the copy dialog (#750168)
The code goes like this: Dialog_Partition_Copy::Get_New_Partition() call Dialog_Base_Partition::Get_New_Partition() Update this->selected_partition with results from running the dialog. return this->selected_partition by value. Save value back to this->selected_partition. Update this->selected_partition some more. return this->selected_partition by value. So there is an unnecessary copy of the partition object returned from the base class Get_New_Partition() function back to the same variable in the derived copy class Get_New_Partition() function. Need to keep the base class Get_New_Partition() function as derived class Dialog_Partition_Resize_Move uses that implementation as it doesn't override it, and it's part of the interface. Avoid this unnecessary copy by moving base class Get_New_Partition() code into a new private function, called prepare_new_partition(), which doesn't return anything. Then have Get_New_Partition() in both classes just return the required partition object. Like this: Dialog_Base_Partition::Get_New_Partition() call prepare_new_partition() return this->selected_partition by value. Dialog_Partition_Copy::Get_New_Partition() call Dialog_Base_Partition::prepare_new_partition() Update this->selected_partition some more. return this->selected_partition by value. Bug 750168 - Reduce the amount of copying of partition objects
This commit is contained in:
parent
90e3ed68fc
commit
8b96f8409f
|
@ -55,7 +55,9 @@ protected:
|
|||
NEW = 1,
|
||||
PASTE = 2
|
||||
};
|
||||
|
||||
|
||||
void prepare_new_partition( Byte_Value sector_size );
|
||||
|
||||
void Set_Confirm_Button( CONFIRMBUTTON button_type ) ;
|
||||
void Set_MinMax_Text( Sector min, Sector max ) ;
|
||||
|
||||
|
|
|
@ -136,7 +136,13 @@ void Dialog_Base_Partition::Set_Resizer( bool extended )
|
|||
this ->show_all_children() ;
|
||||
}
|
||||
|
||||
Partition Dialog_Base_Partition::Get_New_Partition( Byte_Value sector_size )
|
||||
Partition Dialog_Base_Partition::Get_New_Partition( Byte_Value sector_size )
|
||||
{
|
||||
prepare_new_partition( sector_size );
|
||||
return selected_partition;
|
||||
}
|
||||
|
||||
void Dialog_Base_Partition::prepare_new_partition( Byte_Value sector_size )
|
||||
{
|
||||
//set sector size of new partition
|
||||
selected_partition .sector_size = sector_size;
|
||||
|
@ -221,8 +227,6 @@ Partition Dialog_Base_Partition::Get_New_Partition( Byte_Value sector_size )
|
|||
//if the original before value has not changed, then set indicator to keep start sector unchanged
|
||||
if ( ORIG_BEFORE == spinbutton_before .get_value_as_int() )
|
||||
selected_partition .strict_start = TRUE ;
|
||||
|
||||
return selected_partition ;
|
||||
}
|
||||
|
||||
void Dialog_Base_Partition::Set_Confirm_Button( CONFIRMBUTTON button_type )
|
||||
|
|
|
@ -97,7 +97,7 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
|
|||
, ceil( fs .MAX / double(MEBIBYTE) )
|
||||
) ;
|
||||
|
||||
//set global selected_partition (see Dialog_Base_Partition::Get_New_Partition )
|
||||
// Set member variable used in Dialog_Base_Partition::prepare_new_partition()
|
||||
this ->selected_partition = copied_partition ;
|
||||
this ->selected_partition .device_path = selected_partition .device_path ;
|
||||
this ->selected_partition .inside_extended = selected_partition .inside_extended ;
|
||||
|
@ -118,7 +118,7 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
|
|||
Partition Dialog_Partition_Copy::Get_New_Partition( Byte_Value sector_size )
|
||||
{
|
||||
//first call baseclass to get the correct new partition
|
||||
selected_partition = Dialog_Base_Partition::Get_New_Partition( sector_size ) ;
|
||||
Dialog_Base_Partition::prepare_new_partition( sector_size );
|
||||
|
||||
//set proper name and status for partition
|
||||
selected_partition .status = GParted::STAT_COPY ;
|
||||
|
|
Loading…
Reference in New Issue