From 6eed426bf24fe4ddc4c4802ff44b949e74f9d7ee Mon Sep 17 00:00:00 2001 From: Sylvain Henry Date: Thu, 20 May 2021 20:10:26 +0200 Subject: SysTools: make file copy more efficient --- compiler/GHC/Driver/MakeFile.hs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'compiler/GHC/Driver/MakeFile.hs') diff --git a/compiler/GHC/Driver/MakeFile.hs b/compiler/GHC/Driver/MakeFile.hs index 81336912de..f654d0a7fa 100644 --- a/compiler/GHC/Driver/MakeFile.hs +++ b/compiler/GHC/Driver/MakeFile.hs @@ -359,27 +359,20 @@ endMkDependHS logger dflags case makefile_hdl of Nothing -> return () Just hdl -> do - - -- slurp the rest of the original makefile and copy it into the output - let slurp = do - l <- hGetLine hdl - hPutStrLn tmp_hdl l - slurp - - catchIO slurp - (\e -> if isEOFError e then return () else ioError e) - + -- slurp the rest of the original makefile and copy it into the output + SysTools.copyHandle hdl tmp_hdl hClose hdl hClose tmp_hdl -- make sure it's flushed -- Create a backup of the original makefile - when (isJust makefile_hdl) - (SysTools.copy logger dflags ("Backing up " ++ makefile) - makefile (makefile++".bak")) + when (isJust makefile_hdl) $ do + showPass logger dflags ("Backing up " ++ makefile) + SysTools.copyFile makefile (makefile++".bak") -- Copy the new makefile in place - SysTools.copy logger dflags "Installing new makefile" tmp_file makefile + showPass logger dflags "Installing new makefile" + SysTools.copyFile tmp_file makefile ----------------------------------------------------------------- -- cgit v1.2.1