Initialise file system objects only once
The code used to unnecessarily destroy and re-create the file system objects on every scan for file system support tools. Instead only create the file system objects once and just call each object's get_filesystem_support() method on each rescan.
This commit is contained in:
parent
131098a797
commit
5f6656f267
|
@ -38,6 +38,7 @@ public:
|
|||
GParted_Core() ;
|
||||
~GParted_Core() ;
|
||||
|
||||
void init_filesystems() ;
|
||||
void find_supported_filesystems() ;
|
||||
void set_user_devices( const std::vector<Glib::ustring> & user_devices ) ;
|
||||
void set_devices( std::vector<Device> & devices ) ;
|
||||
|
|
|
@ -80,21 +80,14 @@ GParted_Core::GParted_Core()
|
|||
std::cout << "======================" << std::endl ;
|
||||
|
||||
//initialize file system list
|
||||
init_filesystems() ;
|
||||
|
||||
//Determine file system support capabilities for the first time
|
||||
find_supported_filesystems() ;
|
||||
}
|
||||
|
||||
void GParted_Core::find_supported_filesystems()
|
||||
void GParted_Core::init_filesystems()
|
||||
{
|
||||
std::map< FILESYSTEM, FileSystem * >::iterator f ;
|
||||
|
||||
// TODO: determine whether it is safe to initialize this only once
|
||||
for ( f = FILESYSTEM_MAP .begin() ; f != FILESYSTEM_MAP .end() ; f++ ) {
|
||||
if ( f ->second )
|
||||
delete f ->second ;
|
||||
}
|
||||
|
||||
FILESYSTEM_MAP .clear() ;
|
||||
|
||||
FILESYSTEM_MAP[ FS_UNKNOWN ] = NULL ;
|
||||
FILESYSTEM_MAP[ FS_CLEARED ] = NULL ;
|
||||
FILESYSTEM_MAP[ FS_BTRFS ] = new btrfs() ;
|
||||
|
@ -120,6 +113,11 @@ void GParted_Core::find_supported_filesystems()
|
|||
FILESYSTEM_MAP[ FS_LUKS ] = NULL ;
|
||||
FILESYSTEM_MAP[ FS_LINUX_SWRAID ] = NULL ;
|
||||
FILESYSTEM_MAP[ FS_LINUX_SWSUSPEND ] = NULL ;
|
||||
}
|
||||
|
||||
void GParted_Core::find_supported_filesystems()
|
||||
{
|
||||
std::map< FILESYSTEM, FileSystem * >::iterator f ;
|
||||
|
||||
//Iteration of std::map is ordered according to operator< of the key.
|
||||
// Hence the FILESYSTEMS vector is constructed in FILESYSTEM enum
|
||||
|
|
Loading…
Reference in New Issue