Skip to content

Commit

Permalink
[Refactoring] Tweak 'PlutusTx.Data.AssocMap'
Browse files Browse the repository at this point in the history
  • Loading branch information
effectfully committed Sep 19, 2024
1 parent e94d73c commit d277e39
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plutus-tx/src/PlutusTx/Data/AssocMap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,12 @@ safeFromList =
. toOpaque
. List.foldr (uncurry go) []
where
go :: k -> a -> [(BuiltinData, BuiltinData)] -> [(BuiltinData, BuiltinData)]
go k v [] = [(P.toBuiltinData k, P.toBuiltinData v)]
go k v ((k', v') : rest) =
if P.toBuiltinData k == k'
then (P.toBuiltinData k, P.toBuiltinData v) : go k v rest
else (P.toBuiltinData k', P.toBuiltinData v') : go k v rest
else (k', v') : go k v rest

{-# INLINEABLE unsafeFromList #-}
-- | Unsafely create an 'Map' from a list of pairs.
Expand All @@ -238,7 +239,7 @@ noDuplicateKeys (Map m) = go m
(\() -> True)
( \hd tl ->
let k = BI.fst hd
in if member k (Map tl) then False else go tl
in if member' k tl then False else go tl
)

{-# INLINEABLE all #-}
Expand Down

0 comments on commit d277e39

Please sign in to comment.