Skip to content

Commit 8be2e6c

Browse files
committed
This should pass CI
1 parent 6ccbb15 commit 8be2e6c

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/Data/Hashable/Class.hs

+6-9
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ import qualified Data.Text as T
7878
import qualified Data.Text.Array as TA
7979
import qualified Data.Text.Internal as T
8080
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)
8183
import qualified Data.Text.Lazy.Builder as TLB
8284
import Data.Version (Version(..))
8385
import Data.Word (Word8, Word16, Word32, Word64)
@@ -689,15 +691,10 @@ instance Hashable T.Text where
689691
(hashWithSalt salt len)
690692

691693
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
701698

702699
-- | Compute the hash of a ThreadId.
703700
hashThreadId :: ThreadId -> Int

src/Data/Hashable/LowLevel.hs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ module Data.Hashable.LowLevel (
99
hashWord64,
1010
hashPtrWithSalt,
1111
hashByteArrayWithSalt,
12-
hashByteArrayChunck,
1312
k0, -- TODO remove
1413
k1,
1514
withState,

0 commit comments

Comments
 (0)