@@ -436,11 +436,11 @@ encodeUtf8_1 (Text arr off len)
436 loop n1 m1 ptr = go n1 m1
436 loop n1 m1 ptr = go n1 m1
438 offLen = off + len
438 offLen = off + len
439+ poke8 p k v = poke (p `plusPtr` k) (fromIntegral v :: Word8)
440 | n == offLen = return (PS fp 0 m)
441 | n == offLen = return (PS fp 0 m)
441 | otherwise = do
442 | otherwise = do
442− let poke8 k v = poke (ptr `plusPtr` k) (fromIntegral v :: Word8)
443− ensure k act
443+ let ensure k act
444 | size-m >= k = act
444 | size-m >= k = act
445 | otherwise = {-# SCC "resizeUtf8/ensure" #-} do
445 | otherwise = {-# SCC "resizeUtf8/ensure" #-} do
446 let newSize = size `shiftL` 1
446 let newSize = size `shiftL` 1
@@ -451,23 +451,23 @@ encodeUtf8_1 (Text arr off len)
451 {-# INLINE ensure #-}
451 {-# INLINE ensure #-}
452 case A.unsafeIndex arr n of
452 case A.unsafeIndex arr n of
453 w| w <= 0x7F -> ensure 1 $ do
453 w| w <= 0x7F -> ensure 1 $ do
454− poke (ptr `plusPtr` m) (fromIntegral w :: Word8)
454+ poke8 ptr m (fromIntegral w :: Word8)
455 go (n+1) (m+1)
455 go (n+1) (m+1)
456 | w <= 0x7FF -> ensure 2 $ do
456 | w <= 0x7FF -> ensure 2 $ do
457− poke8 m $ (w `shiftR` 6) + 0xC0
457+ poke8 ptr m $ (w `shiftR` 6) + 0xC0
458− poke8 (m+1) $ (w .&. 0x3f) + 0x80
458+ poke8 ptr (m+1) $ (w .&. 0x3f) + 0x80
459 go (n+1) (m+2)
459 go (n+1) (m+2)
460 | 0xD800 <= w && w <= 0xDBFF -> ensure 4 $ do
460 | 0xD800 <= w && w <= 0xDBFF -> ensure 4 $ do
461 let c = ord $ U16.chr2 w (A.unsafeIndex arr (n+1))
461 let c = ord $ U16.chr2 w (A.unsafeIndex arr (n+1))
462− poke8 m $ (c `shiftR` 18) + 0xF0
462+ poke8 ptr m $ (c `shiftR` 18) + 0xF0
463− poke8 (m+1) $ ((c `shiftR` 12) .&. 0x3F) + 0x80
463+ poke8 ptr (m+1) $ ((c `shiftR` 12) .&. 0x3F) + 0x80
464− poke8 (m+2) $ ((c `shiftR` 6) .&. 0x3F) + 0x80
464+ poke8 ptr (m+2) $ ((c `shiftR` 6) .&. 0x3F) + 0x80
465− poke8 (m+3) $ (c .&. 0x3F) + 0x80
465+ poke8 ptr (m+3) $ (c .&. 0x3F) + 0x80
466 go (n+2) (m+4)
466 go (n+2) (m+4)
467 | otherwise -> ensure 3 $ do
467 | otherwise -> ensure 3 $ do
468− poke8 m $ (w `shiftR` 12) + 0xE0
468+ poke8 ptr m $ (w `shiftR` 12) + 0xE0
469− poke8 (m+1) $ ((w `shiftR` 6) .&. 0x3F) + 0x80
469+ poke8 ptr (m+1) $ ((w `shiftR` 6) .&. 0x3F) + 0x80
470− poke8 (m+2) $ (w .&. 0x3F) + 0x80
470+ poke8 ptr (m+2) $ (w .&. 0x3F) + 0x80
471 go (n+1) (m+3)
471 go (n+1) (m+3)