Oops! Back out part of 59aad6977070 - it was wrong
My assertion that it was safe to skip the "do I have 1 byte available?" check
was incorrect.
commit657183396293fd167f459818c8e187e902b19236
authorBryan O'Sullivan <bos@serpentine.com>
dateFri 23 Dec 2011, 12:02 (15 years ago)
parentf0158d3
Data/Text/Encoding.hs+3−1
@@ -167,7 +167,9 @@ encodeUtf8 (Text arr off len) = unsafePerformIO $ do
167167 start newSize n m fp'
168168 {-# INLINE ensure #-}
169169 case A.unsafeIndex arr n of
170− w| w <= 0x7F -> poke8 m w >> go (n+1) (m+1)
170+ w| w <= 0x7F -> ensure 1 $ do
171+ poke8 m w
172+ go (n+1) (m+1)
171173 | w <= 0x7FF -> ensure 2 $ do
172174 poke8 m $ (w `shiftR` 6) + 0xC0
173175 poke8 (m+1) $ (w .&. 0x3f) + 0x80