[gparted] Store pointers to partition objects in DrawingAreaVisualDisk (#750168)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Store pointers to partition objects in DrawingAreaVisualDisk (#750168)
- Date: Sat, 13 Jun 2015 16:11:08 +0000 (UTC)
commit cc1448abd237291e1775aa88b67faa47890a5450
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Sun May 17 10:06:38 2015 +0100
Store pointers to partition objects in DrawingAreaVisualDisk (#750168)
This stops copying of each displayed partition object into the
DrawingAreaVisualDisk class.
Bug 750168 - Reduce the amount of copying of partition objects
include/DrawingAreaVisualDisk.h | 6 +++---
src/DrawingAreaVisualDisk.cc | 14 +++++++-------
2 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/include/DrawingAreaVisualDisk.h b/include/DrawingAreaVisualDisk.h
index d7c7ca2..ccd1a15 100644
--- a/include/DrawingAreaVisualDisk.h
+++ b/include/DrawingAreaVisualDisk.h
@@ -83,9 +83,9 @@ private:
Gdk::Color color ;
Glib::RefPtr<Pango::Layout> pango_layout;
- //real partition
- Partition partition ;
-
+ // Pointer to real partition. (Alias to element in Win_GParted::display_partitions[] vector).
+ const Partition * partition_ptr;
+
std::vector<visual_partition> logicals ;
visual_partition()
diff --git a/src/DrawingAreaVisualDisk.cc b/src/DrawingAreaVisualDisk.cc
index 6be86f4..65d0c5d 100644
--- a/src/DrawingAreaVisualDisk.cc
+++ b/src/DrawingAreaVisualDisk.cc
@@ -92,7 +92,7 @@ void DrawingAreaVisualDisk::set_static_data( const std::vector<Partition> & part
{
visual_partitions .push_back( visual_partition() ) ;
- visual_partitions .back() .partition = partitions[ t ] ;
+ visual_partitions.back().partition_ptr = & partitions[t];
Sector partition_length = partitions[ t ] .get_sector_length() ;
visual_partitions .back() .fraction = partition_length / static_cast<double>( length ) ;
@@ -152,12 +152,12 @@ void DrawingAreaVisualDisk::calc_usage( std::vector<visual_partition> & visual_p
{
for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ )
{
- if ( visual_partitions[ t ] .partition .type != GParted::TYPE_UNALLOCATED &&
- visual_partitions[ t ] .partition .type != GParted::TYPE_EXTENDED )
+ if ( visual_partitions[t].partition_ptr->type != TYPE_UNALLOCATED &&
+ visual_partitions[t].partition_ptr->type != TYPE_EXTENDED )
{
- if ( visual_partitions[ t ] .partition .sector_usage_known() )
+ if ( visual_partitions[t].partition_ptr->sector_usage_known() )
{
- visual_partitions[ t ] .partition .get_usage_triple(
+ visual_partitions[t].partition_ptr->get_usage_triple(
visual_partitions[ t ] .length - BORDER *2,
visual_partitions[ t ] .used_length,
visual_partitions[ t ] .unused_length,
@@ -314,7 +314,7 @@ void DrawingAreaVisualDisk::set_selected( const std::vector<visual_partition> &
if ( visual_partitions[ t ] .logicals .size() > 0 )
set_selected( visual_partitions[t].logicals, partition_ptr );
- if ( ! selected_vp && visual_partitions[t].partition == *partition_ptr )
+ if ( ! selected_vp && *visual_partitions[t].partition_ptr == *partition_ptr )
selected_vp = & visual_partitions[ t ] ;
}
}
@@ -361,7 +361,7 @@ bool DrawingAreaVisualDisk::on_button_press_event( GdkEventButton * event )
if ( selected_vp )
{
- signal_partition_selected.emit( & selected_vp->partition, false );
+ signal_partition_selected.emit( selected_vp->partition_ptr, false );
if ( event ->type == GDK_2BUTTON_PRESS )
signal_partition_activated .emit() ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]