@@ -34,6 +34,7 @@ import Control.Exception (assert)
35import Control.Monad.ST (unsafeIOToST)
35import Control.Monad.ST (unsafeIOToST)
36import Data.Text.Internal (Text(..), empty)
36import Data.Text.Internal (Text(..), empty)
37+import Data.Text.Unsafe (lengthWord16)
37import qualified Data.Text.Array as A
38import qualified Data.Text.Array as A
38import Data.Word (Word16)
39import Data.Word (Word16)
39import Foreign.Marshal.Alloc (allocaBytes)
40import Foreign.Marshal.Alloc (allocaBytes)
@@ -73,13 +74,6 @@ fromPtr ptr len =
73 A.unsafeWrite marr i =<< unsafeIOToST (peek p)
74 A.unsafeWrite marr i =<< unsafeIOToST (peek p)
74 loop (p `plusPtr` 2) (i + 1)
75 loop (p `plusPtr` 2) (i + 1)
76−-- | /O(1)/ Return the length of a 'Text' in units of 'Word16'. This
77−-- is useful for sizing a target array appropriately before using
79−lengthWord16 :: Text -> Int
80−lengthWord16 (Text _arr _off len) = len
81−{-# INLINE lengthWord16 #-}
83-- $lowlevel
77-- $lowlevel
85-- Foreign functions that use UTF-16 internally may return indices in
79-- Foreign functions that use UTF-16 internally may return indices in