Skip to content

Commit

Permalink
Implement pure-Haskell asciiPrefixLength
Browse files Browse the repository at this point in the history
  • Loading branch information
chreekat committed Jan 27, 2024
1 parent a897be5 commit afbaee4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Data/Text/Internal/IsAscii.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module Data.Text.Internal.IsAscii where
import Prelude (Bool(..), Int)
import qualified Data.Char as Char
import {-# SOURCE #-} Data.Text (all)
import qualified Data.ByteString as BS
#else
import Data.Text.Internal.ByteStringCompat (withBS)
import Data.Text.Internal.Unsafe (unsafeWithForeignPtr)
Expand Down Expand Up @@ -64,7 +65,7 @@ isAscii (Text (A.ByteArray arr) off len) =
-- | Length of the longest ASCII prefix.
asciiPrefixLength :: ByteString -> Int
#if defined(PURE_HASKELL)
asciiPrefixLength = P.const 0
asciiPrefixLength = BS.length P.. BS.takeWhile (P.< 0x80)
#else
asciiPrefixLength bs = unsafeDupablePerformIO $ withBS bs $ \ fp len ->
unsafeWithForeignPtr fp $ \src -> do
Expand Down

0 comments on commit afbaee4

Please sign in to comment.