From 7a3fa5a7dd56fc7b41a071c0862075dbdaa14d00 Mon Sep 17 00:00:00 2001 From: Curtis Gedak Date: Mon, 8 Dec 2008 18:23:30 +0000 Subject: [PATCH] Reduced FS_Info cache disk reads svn path=/trunk/; revision=1001 --- ChangeLog | 6 ++++++ include/FS_Info.h | 3 ++- src/FS_Info.cc | 15 +++++++++++++-- src/GParted_Core.cc | 3 ++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 349bf321..0121aa7c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-12-08 Curtis Gedak + + * include/FS_Info.h, + src/FS_Info.cc + src/GParted_Core.cc: Reduced FS_Info cache disk reads. + 2008-12-07 Curtis Gedak * include/Utils.h, diff --git a/include/FS_Info.h b/include/FS_Info.h index f6e3d05f..2f5304e7 100644 --- a/include/FS_Info.h +++ b/include/FS_Info.h @@ -27,13 +27,14 @@ class FS_Info { public: FS_Info() ; + FS_Info( bool do_refresh ) ; ~FS_Info() ; Glib::ustring get_label( const Glib::ustring & path, bool & found ) ; Glib::ustring get_uuid( const Glib::ustring & path ) ; private: void load_fs_info_cache() ; Glib::ustring get_device_entry( const Glib::ustring & path ) ; - Glib::ustring fs_info_cache ; + static Glib::ustring fs_info_cache ; }; }//GParted diff --git a/src/FS_Info.cc b/src/FS_Info.cc index b08de14f..0c5e94c9 100644 --- a/src/FS_Info.cc +++ b/src/FS_Info.cc @@ -19,10 +19,21 @@ namespace GParted { - + +//initialize static data element +Glib::ustring FS_Info::fs_info_cache = ""; + FS_Info::FS_Info() { - load_fs_info_cache() ; + //Ensure that cache has been loaded at least once + if ( fs_info_cache == "" ) + load_fs_info_cache() ; +} + +FS_Info:: FS_Info( bool do_refresh ) +{ + if ( do_refresh ) + load_fs_info_cache() ; } FS_Info::~FS_Info() diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 155bc198..21ef9e4c 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -143,6 +143,7 @@ void GParted_Core::set_devices( std::vector & devices ) { devices .clear() ; Device temp_device ; + FS_Info fs_info( true ) ; //Refresh cache of file system information init_maps() ; @@ -633,7 +634,7 @@ void GParted_Core::set_device_partitions( Device & device ) { int EXT_INDEX = -1 ; char * lp_path ;//we have to free the result of ped_partition_get_path().. - FS_Info fs_info ; //Build cache of file system information + FS_Info fs_info ; //Use cache of file system information //clear partitions device .partitions .clear() ;