[commit: packages/filepath] master: Remove unnecessary `not . null` check (4fdf3b4)

git at git.haskell.org git at git.haskell.org
Thu Mar 19 11:34:20 UTC 2015


Repository : ssh://git@git.haskell.org/filepath

On branch  : master
Link       : http://git.haskell.org/packages/filepath.git/commitdiff/4fdf3b432582118a259faf76d9b9e1d2f43e1322

>---------------------------------------------------------------

commit 4fdf3b432582118a259faf76d9b9e1d2f43e1322
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date:   Thu Oct 23 14:14:30 2014 +0200

    Remove unnecessary `not . null` check
    
    If `res` and `dir` are both null, it doesn't matter which one we return.


>---------------------------------------------------------------

4fdf3b432582118a259faf76d9b9e1d2f43e1322
 System/FilePath/Internal.hs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/System/FilePath/Internal.hs b/System/FilePath/Internal.hs
index 5ea2be5..138fd85 100644
--- a/System/FilePath/Internal.hs
+++ b/System/FilePath/Internal.hs
@@ -552,7 +552,7 @@ dropTrailingPathSeparator x =
 -- > Windows:  takeDirectory "foo\\bar\\\\" == "foo\\bar"
 -- > Windows:  takeDirectory "C:\\" == "C:\\"
 takeDirectory :: FilePath -> FilePath
-takeDirectory x = if isDrive dir || (null res && not (null dir)) then dir else res
+takeDirectory x = if isDrive dir || null res then dir else res
     where
         res = reverse $ dropWhile isPathSeparator $ reverse dir
         dir = dropFileName x



More information about the ghc-commits mailing list