@@ -113,7 +113,10 @@ import TcEnv (tcLookup)
113
113
import Control.Concurrent.Extra
114
114
import Control.Concurrent.STM hiding (orElse )
115
115
import Data.Aeson (toJSON )
116
+ import Data.Binary
117
+ import Data.Binary.Put
116
118
import Data.Bits (shiftR )
119
+ import qualified Data.ByteString.Lazy as LBS
117
120
import Data.Coerce
118
121
import Data.Functor
119
122
import qualified Data.HashMap.Strict as HashMap
@@ -759,35 +762,17 @@ getModSummaryFromImports env fp modTime contents = do
759
762
-- Compute a fingerprint from the contents of `ModSummary`,
760
763
-- eliding the timestamps, the preprocessed source and other non relevant fields
761
764
computeFingerprint opts ModSummary {.. } = do
762
- let moduleUniques =
763
- [ b
764
- | m <- moduleName ms_mod
765
- : map (unLoc . snd ) (ms_srcimps ++ ms_textual_imps)
766
- , b <- toBytes $ uniq $ moduleNameFS m
767
- ] ++
768
- [ b
769
- | (Just p, _) <- ms_srcimps ++ ms_textual_imps
770
- , b <- toBytes $ uniq p
771
- ]
772
- fingerPrintImports <- withArrayLen moduleUniques $ \ len p ->
773
- fingerprintData p len
765
+ let moduleUniques = runPut $ do
766
+ put $ uniq $ moduleNameFS $ moduleName ms_mod
767
+ forM_ (ms_srcimps ++ ms_textual_imps) $ \ (mb_p, m) -> do
768
+ put $ uniq $ moduleNameFS $ unLoc m
769
+ whenJust mb_p $ put . uniq
770
+ fingerPrintImports <- fingerprintFromByteString $ LBS. toStrict moduleUniques
774
771
return $ fingerprintFingerprints $
775
772
[ fingerprintString fp
776
773
, fingerPrintImports
777
774
] ++ map fingerprintString opts
778
775
779
- toBytes :: Int -> [Word8 ]
780
- toBytes w64 =
781
- [ fromIntegral (w64 `shiftR` 56 )
782
- , fromIntegral (w64 `shiftR` 48 )
783
- , fromIntegral (w64 `shiftR` 40 )
784
- , fromIntegral (w64 `shiftR` 32 )
785
- , fromIntegral (w64 `shiftR` 24 )
786
- , fromIntegral (w64 `shiftR` 16 )
787
- , fromIntegral (w64 `shiftR` 8 )
788
- , fromIntegral w64
789
- ]
790
-
791
776
792
777
-- | Parse only the module header
793
778
parseHeader
0 commit comments