Skip to content

Commit

Permalink
Rearrange code again
Browse files Browse the repository at this point in the history
  • Loading branch information
kwxm committed Jul 19, 2024
1 parent 76d6c0c commit abc05f3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions plutus-core/plutus-core/src/PlutusCore/Bitwise.hs
Original file line number Diff line number Diff line change
Expand Up @@ -572,12 +572,14 @@ writeBits bs ixs bits = case unsafeDupablePerformIO . try $ go of
go :: IO ByteString
go = BS.useAsCString bs $ \srcPtr ->
BSI.create len $
\dstPtr ->
let go2 (i:is) (v:vs) = setAtIx dstPtr i v *> go2 is vs
go2 _ _ = pure ()
in do
\dstPtr -> do
copyBytes dstPtr (castPtr srcPtr) len
go2 ixs bits
go2 (setAtIx dstPtr) ixs bits
where go2 f (i:is) (v:vs) = f i v *> go2 f is vs
go2 _ _ _ = pure ()
{-# INLINEABLE go2 #-}
{-# INLINEABLE go #-}

len :: Int
len = BS.length bs
bitLen :: Integer
Expand Down

0 comments on commit abc05f3

Please sign in to comment.