summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-09-28 11:46:44 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-09-30 00:57:44 -0400
commite0923b98a243809f08245b2ff04ecbe074b55873 (patch)
tree6002b4a30a0341f5478f4f43f0340ee78909f767
parent205f0f921590a6365ed1c36d34f557a1e387bfa2 (diff)
downloadhaskell-e0923b98a243809f08245b2ff04ecbe074b55873.tar.gz
ghc-boot: Eliminate unnecessary use of getEnvironment
Previously we were using `System.Environment.getEnvironment`, which decodes all environment variables into Haskell `String`s, where a simple environment lookup would do. This made the compiler's allocations unnecessarily dependent on the environment. Fixes #20431.
-rw-r--r--libraries/ghc-boot/GHC/HandleEncoding.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/libraries/ghc-boot/GHC/HandleEncoding.hs b/libraries/ghc-boot/GHC/HandleEncoding.hs
index 3c4c10c70f..54c5582102 100644
--- a/libraries/ghc-boot/GHC/HandleEncoding.hs
+++ b/libraries/ghc-boot/GHC/HandleEncoding.hs
@@ -10,8 +10,8 @@ import System.IO
-- GHC produces output regardless of OS.
configureHandleEncoding :: IO ()
configureHandleEncoding = do
- env <- getEnvironment
- case lookup "GHC_CHARENC" env of
+ mb_val <- lookupEnv "GHC_CHARENC"
+ case mb_val of
Just "UTF-8" -> do
hSetEncoding stdout utf8
hSetEncoding stderr utf8