]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/MIMEType/Guess.hs
Optimized as possible as I can.
[Lucu.git] / Network / HTTP / Lucu / MIMEType / Guess.hs
index 93a1479837fb4c98f015faa163f48430d9778dd3..65bf3a607cc4b8306d5d7114485fb7452817ffe1 100644 (file)
@@ -30,14 +30,16 @@ type ExtMap = Map String MIMEType
 -- |Guess the MIME Type of file.
 guessTypeByFileName :: ExtMap -> FilePath -> Maybe MIMEType
 guessTypeByFileName extMap fpath
-    = let ext = last $ splitBy (== '.') fpath
+    = extMap `seq` fpath `seq`
+      let ext = last $ splitBy (== '.') fpath
       in
         M.lookup ext extMap >>= return
 
 -- |Read an Apache mime.types and parse it.
 parseExtMapFile :: FilePath -> IO ExtMap
 parseExtMapFile fpath
-    = do file <- B.readFile fpath
+    = fpath `seq`
+      do file <- B.readFile fpath
          case parse (allowEOF extMapP) file of
            (Success xs, _) -> return $ compile xs
            (_, input')     -> let near = B.unpack $ B.take 100 input'