[gparted] Simplify GParted_Core::get_fs()



commit 49664f3ca38f3fa0d70304a44bfa795f8d88244e
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Thu Nov 12 19:14:48 2015 +0000

    Simplify GParted_Core::get_fs()
    
    get_fs() used to work by (1) returning the supported capabilities of the
    requested file system found in the FILESYSTEMS vector; (2) if not found
    return the supported capabilities for file system FS_UNKNOWN; and (3)
    if that wasn't found either, create a not supported capabilities set for
    FS_UNKNOWN and return that.
    
    This is more complicated that required.  Also the not supported
    capabilities set, as created by struct FS() constructor, is the same as
    that created in file_supported_filesystems() local variable fs_notsupp.
    
    Simplify get_fs() just using a single not found code path returning a
    not supported capabilities set.

 src/GParted_Core.cc |   17 +++++------------
 1 files changed, 5 insertions(+), 12 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 82eee10..cd9c280 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -932,26 +932,19 @@ const std::vector<FS> & GParted_Core::get_filesystems() const
        return FILESYSTEMS ;
 }
 
+// Return supported capabilities of the file system type or, if not found, not supported
+// capabilities set.
 const FS & GParted_Core::get_fs( GParted::FILESYSTEM filesystem ) const 
 {
-       unsigned int unknown ;
-
-       unknown = FILESYSTEMS .size() ;
        for ( unsigned int t = 0 ; t < FILESYSTEMS .size() ; t++ )
        {
                if ( FILESYSTEMS[ t ] .filesystem == filesystem )
                        return FILESYSTEMS[ t ] ;
-               else if ( FILESYSTEMS[ t ] .filesystem == FS_UNKNOWN )
-                       unknown = t ;
        }
 
-       if ( unknown == FILESYSTEMS .size() ) {
-               // This shouldn't happen, but just in case...
-               static FS fs;
-               fs .filesystem = FS_UNKNOWN ;
-               return fs ;
-       } else
-               return FILESYSTEMS[ unknown ] ;
+       static FS fs_notsupp;
+       fs_notsupp.filesystem = FS_UNKNOWN;
+       return fs_notsupp;
 }
 
 //Return all libparted's partition table types in it's preferred ordering,


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