From 609f68f80a50cfcfd3744fab9b72549a7782ca2a Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Wed, 26 Dec 2007 04:24:12 +0100 Subject: Don't bother checking executable bits of items in $PATH, yields a significant speed-up darcs-hash:20071226032412-a5988-0de67a84893bbcf766a111afe329d6656fb51887.gz --- XMonad/Prompt/Shell.hs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'XMonad/Prompt/Shell.hs') diff --git a/XMonad/Prompt/Shell.hs b/XMonad/Prompt/Shell.hs index 295c0fa..29dba38 100644 --- a/XMonad/Prompt/Shell.hs +++ b/XMonad/Prompt/Shell.hs @@ -89,20 +89,12 @@ getCommands :: IO [String] getCommands = do p <- getEnv "PATH" `catch` const (return []) let ds = split ':' p - fp d f = d ++ "/" ++ f es <- forM ds $ \d -> do exists <- doesDirectoryExist d if exists - then getDirectoryContents d >>= filterM (isExecutable . fp d) + then getDirectoryContents d else return [] - return . uniqSort . concat $ es - -isExecutable :: FilePath ->IO Bool -isExecutable f = do - fe <- doesFileExist f - if fe - then fmap executable $ getPermissions f - else return False + return . uniqSort . filter ((/= '.') . head) . concat $ es split :: Eq a => a -> [a] -> [[a]] split _ [] = [] -- cgit v1.2.3