Skip to content

Commit

Permalink
Use native (and naive) UTF8 decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Aug 30, 2021
1 parent b1226ff commit e8f48b9
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 347 deletions.
160 changes: 0 additions & 160 deletions cbits/cbits.c

This file was deleted.

11 changes: 0 additions & 11 deletions include/text_cbits.h

This file was deleted.

20 changes: 1 addition & 19 deletions src/Data/Text.hs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ import qualified Data.Text.Internal.Fusion.Common as S
import Data.Text.Encoding (decodeUtf8', encodeUtf8)
import Data.Text.Internal.Fusion (stream, reverseStream, unstream)
import Data.Text.Internal.Private (span_)
import Data.Text.Internal (Text(..), empty, firstf, mul, safe, text)
import Data.Text.Internal (Text(..), empty, firstf, mul, safe, text, append)
import Data.Text.Internal.Unsafe.Char (unsafeWrite, unsafeChr8)
import Data.Text.Show (singleton, unpack, unpackCString#)
import qualified Prelude as P
Expand Down Expand Up @@ -446,24 +446,6 @@ snoc :: Text -> Char -> Text
snoc t c = unstream (S.snoc (stream t) (safe c))
{-# INLINE snoc #-}

-- | /O(n)/ Appends one 'Text' to the other by copying both of them
-- into a new 'Text'.
append :: Text -> Text -> Text
append a@(Text arr1 off1 len1) b@(Text arr2 off2 len2)
| len1 == 0 = b
| len2 == 0 = a
| len > 0 = Text (A.run x) 0 len
| otherwise = overflowError "append"
where
len = len1+len2
x :: ST s (A.MArray s)
x = do
arr <- A.new len
A.copyI len1 arr 0 arr1 off1
A.copyI len2 arr len1 arr2 off2
return arr
{-# NOINLINE append #-}

-- | /O(1)/ Returns the first character of a 'Text', which must be
-- non-empty.
head :: Text -> Char
Expand Down
Loading

0 comments on commit e8f48b9

Please sign in to comment.