[Git][ghc/ghc][master] compiler: use fromAscList when applicable
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Sat Feb 22 01:19:10 UTC 2025
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
1c8e608a by Cheng Shao at 2025-02-21T20:18:41-05:00
compiler: use fromAscList when applicable
This patch uses fromAscList (with O(n) complexity) instead of fromList
(with O(nlogn) complexity) in certain Binary instances. It's safe to
do so since the corresponding serialization logic is based on toList
(same as toAscList).
- - - - -
1 changed file:
- compiler/GHC/Utils/Binary.hs
Changes:
=====================================
compiler/GHC/Utils/Binary.hs
=====================================
@@ -940,8 +940,8 @@ instance Binary a => Binary [a] where
-- | This instance doesn't rely on the determinism of the keys' 'Ord' instance,
-- so it works e.g. for 'Name's too.
instance (Binary a, Ord a) => Binary (Set a) where
- put_ bh s = put_ bh (Set.toList s)
- get bh = Set.fromList <$> get bh
+ put_ bh s = put_ bh (Set.toAscList s)
+ get bh = Set.fromAscList <$> get bh
instance Binary a => Binary (NonEmpty a) where
put_ bh = put_ bh . NonEmpty.toList
@@ -2086,5 +2086,5 @@ source location as part of a larger structure.
--------------------------------------------------------------------------------
instance (Binary v) => Binary (IntMap v) where
- put_ bh m = put_ bh (IntMap.toList m)
- get bh = IntMap.fromList <$> get bh
+ put_ bh m = put_ bh (IntMap.toAscList m)
+ get bh = IntMap.fromAscList <$> get bh
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1c8e608a84b9d54abb352b59a592d4669872517e
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1c8e608a84b9d54abb352b59a592d4669872517e
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20250221/44002d45/attachment-0001.html>
More information about the ghc-commits
mailing list