diff options
| author | Bartosz Nitka <niteria@gmail.com> | 2016-06-06 08:54:17 -0700 |
|---|---|---|
| committer | Bartosz Nitka <niteria@gmail.com> | 2016-06-06 10:34:47 -0700 |
| commit | 1937ef1c506b538f0f93cd290fa4a42fc85ab769 (patch) | |
| tree | 24a40281aa6fc8f2c6b83759adaea5a3141b40e8 /compiler/utils | |
| parent | 3e7a876a9cdf10e5153421b4905928b9de981778 (diff) | |
| download | haskell-1937ef1c506b538f0f93cd290fa4a42fc85ab769.tar.gz | |
Make UnitIdMap a deterministic map
This impacts at least the order in which version macros are
generated. It's pretty hard to track what kind of nondeterminism
is benign and this should have no performance impact as the number
of packages should be relatively small.
Test Plan: ./validate
Reviewers: simonmar, austin, bgamari, ezyang
Reviewed By: ezyang
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2308
GHC Trac Issues: #4012
Diffstat (limited to 'compiler/utils')
| -rw-r--r-- | compiler/utils/UniqDFM.hs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/utils/UniqDFM.hs b/compiler/utils/UniqDFM.hs index 6e6292ec3c..8ed1451eea 100644 --- a/compiler/utils/UniqDFM.hs +++ b/compiler/utils/UniqDFM.hs @@ -40,7 +40,7 @@ module UniqDFM ( elemUDFM, foldUDFM, eltsUDFM, - filterUDFM, + filterUDFM, filterUDFM_Directly, isNullUDFM, sizeUDFM, intersectUDFM, udfmIntersectUFM, @@ -265,6 +265,11 @@ eltsUDFM (UDFM m _i) = filterUDFM :: (elt -> Bool) -> UniqDFM elt -> UniqDFM elt filterUDFM p (UDFM m i) = UDFM (M.filter (\(TaggedVal v _) -> p v) m) i +filterUDFM_Directly :: (Unique -> elt -> Bool) -> UniqDFM elt -> UniqDFM elt +filterUDFM_Directly p (UDFM m i) = UDFM (M.filterWithKey p' m) i + where + p' k (TaggedVal v _) = p (getUnique k) v + -- | Converts `UniqDFM` to a list, with elements in deterministic order. -- It's O(n log n) while the corresponding function on `UniqFM` is O(n). udfmToList :: UniqDFM elt -> [(Unique, elt)] |
