diff options
author | Ben Gamari <ben@smart-cactus.org> | 2021-09-28 11:46:44 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2021-09-28 11:48:34 -0400 |
commit | ee68cb0c9a165ea1b101f2f6230644748e4c5e9f (patch) | |
tree | 9fcdc8ebce14dfde9875f21c4fe140ed198117d7 | |
parent | 26f24aeca7784f9f9a2a49bce42eaeb60b94d39f (diff) | |
download | haskell-wip/T20431.tar.gz |
ghc-boot: Eliminate unnecessary use of getEnvironmentwip/T20431
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 |