@@ -14,7 +14,7 @@ import Data.Set (Set)
14
14
import qualified Data.Set as Set
15
15
import GHC.Stack (HasCallStack )
16
16
import Test.Cardano.Ledger.Binary.Random (QC (.. ))
17
- import Test.Cardano.Ledger.Core.Arbitrary (uniformSubMap )
17
+ import Test.Cardano.Ledger.Core.Arbitrary (uniformSubMap , uniformSubSet )
18
18
import Test.QuickCheck hiding (Fixed , total )
19
19
20
20
-- ==========================================================================
@@ -122,18 +122,7 @@ subsetFromSetWithSize mess set n
122
122
++ show (Set. size set)
123
123
)
124
124
mess
125
- -- It is faster to remove extra elements, when we need to drop more than a half
126
- | Set. size set `div` 2 < n = fst <$> help (flip const ) set Set. empty (Set. size set - n)
127
- -- It is faster to pick out random elements when we only need under a half of the original set.
128
- | otherwise = snd <$> help seq set Set. empty n
129
- where
130
- help optSeq ! source target count
131
- | count <= 0 = pure (source, target)
132
- | otherwise = do
133
- (item, source') <- itemFromSet ((" subsetFromSetWithSize " ++ show n) : mess) source
134
- -- To avoid a memory leak we only force the target when it is the set we want to keep.
135
- let target' = Set. insert item target
136
- target' `optSeq` help optSeq source' target' (count - 1 )
125
+ | otherwise = uniformSubSet (Just n) set QC
137
126
138
127
-- | Generate a larger map, from a smaller map 'subset'. The new larger map, should have all the
139
128
-- keys and values of the smaller map.
0 commit comments