on master help sign in
Deduplicate
commite661fd8e30da68fc93378a541a89950bf42f358c authorBryan O'Sullivan <bos@serpentine.com> dateFri 22 Aug 2014, 09:35 (12 years ago) parente33c89b
1 file changed+2−14
Data/Text/Internal/Builder.hs+2−14
Data/Text/Internal/Builder.hs+2−14
@@ -58,13 +58,11 @@ module Data.Text.Internal.Builder
5858 ) where
5959
6060import Control.Monad.ST (ST, runST)
61−import Data.Bits ((.&.))
6261import Data.Monoid (Monoid(..))
6362import Data.Text.Internal (Text(..))
6463import Data.Text.Internal.Lazy (smallChunkSize)
6564import Data.Text.Unsafe (inlineInterleaveST)
66−import Data.Text.Internal.Unsafe.Char (ord, unsafeWrite)
67−import Data.Text.Internal.Unsafe.Shift (shiftR)
65+import Data.Text.Internal.Unsafe.Char (unsafeWrite)
6866import Prelude hiding (map, putChar)
6967
7068import qualified Data.String as String
@@ -127,17 +125,7 @@ empty = Builder (\ k buf -> k buf)
127125-- * @'toLazyText' ('singleton' c) = 'L.singleton' c@
128126--
129127singleton :: Char -> Builder
130−singleton c = writeAtMost 2 $ \ marr o ->
131− if n < 0x10000
132− then A.unsafeWrite marr o (fromIntegral n) >> return 1
133− else do
134− A.unsafeWrite marr o lo
135− A.unsafeWrite marr (o+1) hi
136− return 2
137− where n = ord c
138− m = n - 0x10000
139− lo = fromIntegral $ (m `shiftR` 10) + 0xD800
140− hi = fromIntegral $ (m .&. 0x3FF) + 0xDC00
128+singleton c = writeAtMost 2 $ \ marr o -> unsafeWrite marr o c
141129{-# INLINE singleton #-}
142130
143131------------------------------------------------------------------------