diff options
author | Ben Gamari <ben@smart-cactus.org> | 2021-09-28 11:46:44 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-09-30 00:57:44 -0400 |
commit | e0923b98a243809f08245b2ff04ecbe074b55873 (patch) | |
tree | 6002b4a30a0341f5478f4f43f0340ee78909f767 | |
parent | 205f0f921590a6365ed1c36d34f557a1e387bfa2 (diff) | |
download | haskell-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.hs | 4 |
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 |