From 1d370f586650277a6a3b87b7ab14e6c3e1949c3c Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Wed, 30 Sep 2015 21:07:41 +0200 Subject: [PATCH 1/3] Speed up map-file loading --- elisp/ghc-process.el | 2 +- src/GHCMod.hs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/elisp/ghc-process.el b/elisp/ghc-process.el index 165d2f9..3c80d8c 100644 --- a/elisp/ghc-process.el +++ b/elisp/ghc-process.el @@ -69,7 +69,7 @@ (save-restriction (widen) (process-send-region pro (point-min) (point-max)))) - (process-send-string pro "\004\n") + (process-send-string pro "\n\004\n") (condition-case nil (let ((inhibit-quit nil)) (while ghc-process-file-mapping diff --git a/src/GHCMod.hs b/src/GHCMod.hs index ea64153..e770384 100644 --- a/src/GHCMod.hs +++ b/src/GHCMod.hs @@ -506,10 +506,11 @@ getFileSourceFromStdin :: IO String getFileSourceFromStdin = do let loop' acc = do line <- getLine - if not (null line) && last line == '\EOT' - then return $ acc ++ init line - else loop' (acc++line++"\n") - loop' "" + if line == "\EOT" + then return $ intercalate "\n" $ reverse $ ((init line):acc) + else loop' (line:acc) + loop' [] + -- Someone please already rewrite the cmdline parsing code *weep* :'( wrapGhcCommands :: (IOish m, GmOut m) => Options -> [String] -> m () From fc7b059f92901cad1f7084810de82e1576475e89 Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Thu, 1 Oct 2015 08:54:13 +0200 Subject: [PATCH 2/3] Update from input by @lierdakil --- src/GHCMod.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/GHCMod.hs b/src/GHCMod.hs index e770384..837356c 100644 --- a/src/GHCMod.hs +++ b/src/GHCMod.hs @@ -502,15 +502,15 @@ legacyInteractiveLoop symdbreq world = do , GHandler $ \(SomeException e) -> gmErrStrLn (show e) >> return "" ] -getFileSourceFromStdin :: IO String getFileSourceFromStdin = do - let loop' acc = do - line <- getLine - if line == "\EOT" - then return $ intercalate "\n" $ reverse $ ((init line):acc) - else loop' (line:acc) - loop' [] - + linesIn <- readStdin' + return (intercalate "\n" linesIn) + where + readStdin' = do + x <- getLine + if x/="\EOT" + then fmap (x:) readStdin' + else return [] -- Someone please already rewrite the cmdline parsing code *weep* :'( wrapGhcCommands :: (IOish m, GmOut m) => Options -> [String] -> m () From a23b83225889da13bd098f41d1b272c2c841af4d Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Sat, 3 Oct 2015 16:00:46 +0200 Subject: [PATCH 3/3] Make travis happy for 7.8 version --- src/GHCMod.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/GHCMod.hs b/src/GHCMod.hs index 837356c..ed1aee9 100644 --- a/src/GHCMod.hs +++ b/src/GHCMod.hs @@ -502,6 +502,7 @@ legacyInteractiveLoop symdbreq world = do , GHandler $ \(SomeException e) -> gmErrStrLn (show e) >> return "" ] +getFileSourceFromStdin :: IO String getFileSourceFromStdin = do linesIn <- readStdin' return (intercalate "\n" linesIn)