From 9af07e05719cba32911e8832eeee96bccb14ea1d Mon Sep 17 00:00:00 2001 From: simonpj Date: Mon, 23 May 2005 09:50:26 +0000 Subject: [PATCH] [project @ 2005-05-23 09:50:26 by simonpj] Clarify code for splitLongestPrefix; no effect on behaviour --- ghc/compiler/utils/Util.lhs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ghc/compiler/utils/Util.lhs b/ghc/compiler/utils/Util.lhs index 59bc87e..b16f6eb 100644 --- a/ghc/compiler/utils/Util.lhs +++ b/ghc/compiler/utils/Util.lhs @@ -913,11 +913,12 @@ joinFileName dir fname = dir ++ '/':fname -- string is returned in the first component (and the second one is just -- empty). splitLongestPrefix :: String -> (Char -> Bool) -> (String,String) -splitLongestPrefix s pred - = case pre of - [] -> (reverse suf, []) - (_:pre) -> (reverse pre, reverse suf) - where (suf,pre) = break pred (reverse s) +splitLongestPrefix str pred + | null r_pre = (str, []) + | otherwise = (reverse (tail r_pre), reverse r_suf) + -- 'tail' drops the char satisfying 'pred' + where + (r_suf, r_pre) = break pred (reverse str) replaceFilenameSuffix :: FilePath -> Suffix -> FilePath replaceFilenameSuffix file suf = basenameOf file `joinFileExt` suf -- 1.7.10.4