@@ -78,6 +78,8 @@ import qualified Data.Text as T
78
78
import qualified Data.Text.Array as TA
79
79
import qualified Data.Text.Internal as T
80
80
import qualified Data.Text.Lazy as TL
81
+ import qualified Data.Text.Internal.Encoding.Fusion as TL
82
+ import qualified Data.Text.Internal.Lazy.Fusion as TL hiding (unstream )
81
83
import qualified Data.Text.Lazy.Builder as TLB
82
84
import Data.Version (Version (.. ))
83
85
import Data.Word (Word8 , Word16 , Word32 , Word64 )
@@ -689,15 +691,10 @@ instance Hashable T.Text where
689
691
(hashWithSalt salt len)
690
692
691
693
instance Hashable TL. Text where
692
- hashWithSalt salt txt =
693
- unsafePerformIO $
694
- withState k0 k1 $ \ state ->
695
- fmap (hashInt salt) $ TL. foldlChunks (step state) (pure 0 ) $
696
- TLB. toLazyTextWith 8 $ TLB. fromLazyText txt
697
- where
698
- step state prev (T. Text arr off len) = do
699
- prevLen <- prev
700
- (prevLen + len) <$ hashByteArrayChunck (TA. aBA arr) (off `shiftL` 1 ) (len `shiftL` 1 ) state
694
+ hashWithSalt salt = -- piggy back on lazy bytestring instead
695
+ hashWithSalt salt . TL. unstream .
696
+ TL. restreamUtf16LE . -- I don't think the encoding matters, best would be fastest
697
+ TL. stream
701
698
702
699
-- | Compute the hash of a ThreadId.
703
700
hashThreadId :: ThreadId -> Int
0 commit comments