summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2020-03-19 00:33:40 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-07-22 20:18:11 -0400
commit5b8902e3975b8275b027b3d1cfe0d8cb8fdd3d13 (patch)
tree37430cc3a58676c3808778243b7d35dc387b0b7e
parent5536ed28b676106810e65bac15305ad2b1b0babd (diff)
downloadhaskell-5b8902e3975b8275b027b3d1cfe0d8cb8fdd3d13.tar.gz
Encoding: Remove redundant use of withForeignPtr
-rw-r--r--compiler/GHC/Utils/Encoding.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/GHC/Utils/Encoding.hs b/compiler/GHC/Utils/Encoding.hs
index 8a6e863bae..51ebc20ead 100644
--- a/compiler/GHC/Utils/Encoding.hs
+++ b/compiler/GHC/Utils/Encoding.hs
@@ -38,6 +38,7 @@ module GHC.Utils.Encoding (
import GHC.Prelude
import Foreign
+import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
import Data.Char
import qualified Data.Char as Char
import Numeric
@@ -155,8 +156,8 @@ utf8DecodeByteString (BS.PS fptr offset len)
utf8DecodeStringLazy :: ForeignPtr Word8 -> Int -> Int -> [Char]
utf8DecodeStringLazy fp offset (I# len#)
- = unsafeDupablePerformIO $ withForeignPtr fp $ \ptr ->
- let !(Ptr a#) = ptr `plusPtr` offset in
+ = unsafeDupablePerformIO $ do
+ let !(Ptr a#) = unsafeForeignPtrToPtr fp `plusPtr` offset
utf8DecodeLazy# (touchForeignPtr fp) (utf8DecodeCharAddr# a#) len#
-- Note that since utf8DecodeLazy# returns a thunk the lifetime of the
-- ForeignPtr actually needs to be longer than the lexical lifetime