@@ -658,15 +658,17 @@ words :: Text -> [Text]
658words (Text arr off len) = loop0 off off
658words (Text arr off len) = loop0 off off
660 loop0 start n
660 loop0 start n
661+ | n >= len = if start == n
663+ else [Text arr (start+off) (n-start)]
661− | isSpace (unsafeChr c) = if start == n
664+ | isSpace (unsafeChr c) =
662− then loop0 (start+1) (start+1)
666+ then loop0 (start+1) (start+1)
663− else (Text arr start (n-start)):loop0 (n+1) (n+1)
667+ else Text arr (start+off) (n-start) : loop0 (n+1) (n+1)
668+ | otherwise = if c < 0xD800 || c > 0xDBFF
664− | n < (off+len) = loop0 start (n+1)
669+ then loop0 start (n+1)
665− | otherwise = if start == n
667− else [(Text arr start (n-start))]
670+ else loop0 start (n+2)
669− c = arr `A.unsafeIndex` n
671+ where c = arr `A.unsafeIndex` n
670{-# INLINE words #-}
672{-# INLINE words #-}
672-- | /O(n)/ Breaks a 'Text' up into a list of 'Text's at
674-- | /O(n)/ Breaks a 'Text' up into a list of 'Text's at