File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
hnix-store-core/src/System/Nix Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -18,14 +18,19 @@ encode c = T.pack $ concatMap char32 [nChar - 1, nChar - 2 .. 0]
1818 -- d58a11e019813902b6c4547ca61a127938b2cc20.
1919 nChar = fromIntegral $ ((BS. length c * 8 - 1 ) `div` 5 ) + 1
2020
21+ byte = BS. index c . fromIntegral
22+
23+ -- May need to switch to a more efficient calculation at some
24+ -- point.
25+ bAsInteger :: Integer
26+ bAsInteger = sum [fromIntegral (byte j) * (256 ^ j)
27+ | j <- [0 .. BS. length c - 1 ]
28+ ]
29+
2130 char32 :: Integer -> [Char ]
2231 char32 i = [digits32 V. ! digitInd]
2332 where
24- byte j = BS. index c (fromIntegral j)
25- fromIntegral' :: Num b => Integer -> b
26- fromIntegral' = fromIntegral
27- digitInd = fromIntegral' $
28- sum [fromIntegral (byte j) * (256 ^ j)
29- | j <- [0 .. BS. length c - 1 ]]
33+ digitInd = fromIntegral $
34+ bAsInteger
3035 `div` (32 ^ i)
3136 `mod` 32
You can’t perform that action at this time.
0 commit comments