Skip to content

Commit

Permalink
Remove inlinePerformIO
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Sep 15, 2020
1 parent 43077f6 commit 444c475
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
6 changes: 0 additions & 6 deletions Data/ByteString/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ module Data.ByteString.Internal (

-- * Deprecated and unmentionable
accursedUnutterablePerformIO, -- :: IO a -> a
inlinePerformIO, -- :: IO a -> a

-- * Exported compatibility shim
plusForeignPtr
Expand Down Expand Up @@ -719,11 +718,6 @@ overflowError fun = error $ "Data.ByteString." ++ fun ++ ": size overflow"
accursedUnutterablePerformIO :: IO a -> a
accursedUnutterablePerformIO (IO m) = case m realWorld# of (# _, r #) -> r

inlinePerformIO :: IO a -> a
inlinePerformIO = accursedUnutterablePerformIO
{-# INLINE inlinePerformIO #-}
{-# DEPRECATED inlinePerformIO "If you think you know what you are doing, use 'System.IO.Unsafe.unsafePerformIO'. If you are sure you know what you are doing, use 'unsafeDupablePerformIO'. If you enjoy sharing an address space with a malevolent agent of chaos, try 'accursedUnutterablePerformIO'." #-}

-- ---------------------------------------------------------------------
--
-- Standard C functions
Expand Down
2 changes: 1 addition & 1 deletion tests/Hash.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ eq a@(S.BS p l) b@(S.BS p' l')
| p == p' = True -- short cut for the same string
| otherwise = compare a b == EQ
where
compare (S.BS fp1 len1) (S.BS fp2 len2) = S.inlinePerformIO $
compare (S.BS fp1 len1) (S.BS fp2 len2) = S.accursedUnutterablePerformIO $
withForeignPtr fp1 $ \p1 ->
withForeignPtr fp2 $ \p2 ->
cmp p1 p2 0 len1 len2
Expand Down
6 changes: 3 additions & 3 deletions tests/Words.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ compareBytes :: ByteString -> ByteString -> Ordering
compareBytes (BS fp1 len1) (BS fp2 len2)
| len1 == 0 && len2 == 0 = EQ -- short cut for empty strings
| fp1 == fp2 && len1 == len2 = EQ -- short cut for the same string
-- | max len1 len2 > 1 = inlinePerformIO $
| otherwise = inlinePerformIO $
-- | max len1 len2 > 1 = accursedUnutterablePerformIO $
| otherwise = accursedUnutterablePerformIO $
withForeignPtr fp1 $ \p1 ->
withForeignPtr fp2 $ \p2 -> do
i <- memcmp p1 p2 (fromIntegral $ min len1 len2)
Expand All @@ -49,7 +49,7 @@ compareBytes (BS fp1 len1) (BS fp2 len2)


{-
| otherwise = inlinePerformIO $
| otherwise = accursedUnutterablePerformIO $
withForeignPtr fp1 $ \p1 ->
withForeignPtr fp2 $ \p2 ->
cmp (p1 `plusPtr` off1)
Expand Down
8 changes: 4 additions & 4 deletions tests/test-compare.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ compareBytes :: ByteString -> ByteString -> Ordering
compareBytes (BS fp1 len1) (BS fp2 len2)
-- | len1 == 0 && len2 == 0 = EQ -- short cut for empty strings
-- | fp1 == fp2 && len1 == len2 = EQ -- short cut for the same string
| otherwise = inlinePerformIO $
| otherwise = accursedUnutterablePerformIO $
withForeignPtr fp1 $ \p1 ->
withForeignPtr fp2 $ \p2 ->
cmp p1 p2 0 len1 len2

cmp :: Ptr Word8 -> Ptr Word8 -> Int -> Int -> Int-> IO Ordering
cmp p1 p2 n len1 len2
| n == len1 = if n == len2 then return EQ else return LT
Expand All @@ -56,11 +56,11 @@ cmp p1 p2 n len1 len2
EQ -> cmp p1 p2 (n+1) len1 len2
LT -> return LT
GT -> return GT

compareBytesC (BS x1 l1) (BS x2 l2)
| l1 == 0 && l2 == 0 = EQ -- short cut for empty strings
| x1 == x2 && l1 == l2 = EQ -- short cut for the same string
| otherwise = inlinePerformIO $
| otherwise = accursedUnutterablePerformIO $
withForeignPtr x1 $ \p1 ->
withForeignPtr x2 $ \p2 -> do
i <- memcmp p1 p2 (fromIntegral $ min l1 l2)
Expand Down

0 comments on commit 444c475

Please sign in to comment.