@@ -191,39 +191,29 @@ main = do
191
191
192
192
-- fromList
193
193
, bgroup " fromList"
194
- [ bgroup name
195
- [ bgroup " long"
196
- [ bench " String" $ whnf fl1 elems
197
- , bench " ByteString" $ whnf fl2 elemsBS
198
- , bench " Int" $ whnf fl3 elemsI
199
- ]
200
- , bgroup " short"
201
- [ bench " String" $ whnf fl1 elemsDup
202
- , bench " ByteString" $ whnf fl2 elemsDupBS
203
- , bench " Int" $ whnf fl3 elemsDupI
204
- ]
194
+ [ bgroup " long"
195
+ [ bench " String" $ whnf HM. fromList elems
196
+ , bench " ByteString" $ whnf HM. fromList elemsBS
197
+ , bench " Int" $ whnf HM. fromList elemsI
198
+ ]
199
+ , bgroup " short"
200
+ [ bench " String" $ whnf HM. fromList elemsDup
201
+ , bench " ByteString" $ whnf HM. fromList elemsDupBS
202
+ , bench " Int" $ whnf HM. fromList elemsDupI
205
203
]
206
- | (name,fl1,fl2,fl3)
207
- <- [(" Base" ,HM. fromList,HM. fromList,HM. fromList)
208
- ,(" insert" ,fromList_insert,fromList_insert,fromList_insert)]
209
204
]
210
- -- fromList
205
+ -- fromListWith
211
206
, bgroup " fromListWith"
212
- [ bgroup name
213
- [ bgroup " long"
214
- [ bench " String" $ whnf (fl1 (+) ) elems
215
- , bench " ByteString" $ whnf (fl2 (+) ) elemsBS
216
- , bench " Int" $ whnf (fl3 (+) ) elemsI
217
- ]
218
- , bgroup " short"
219
- [ bench " String" $ whnf (fl1 (+) ) elemsDup
220
- , bench " ByteString" $ whnf (fl2 (+) ) elemsDupBS
221
- , bench " Int" $ whnf (fl3 (+) ) elemsDupI
222
- ]
207
+ [ bgroup " long"
208
+ [ bench " String" $ whnf (HM. fromListWith (+) ) elems
209
+ , bench " ByteString" $ whnf (HM. fromListWith (+) ) elemsBS
210
+ , bench " Int" $ whnf (HM. fromListWith (+) ) elemsI
211
+ ]
212
+ , bgroup " short"
213
+ [ bench " String" $ whnf (HM. fromListWith (+) ) elemsDup
214
+ , bench " ByteString" $ whnf (HM. fromListWith (+) ) elemsDupBS
215
+ , bench " Int" $ whnf (HM. fromListWith (+) ) elemsDupI
223
216
]
224
- | (name,fl1,fl2,fl3)
225
- <- [(" Base" ,HM. fromListWith,HM. fromListWith,HM. fromListWith)
226
- ,(" insert" ,fromListWith_insert,fromListWith_insert,fromListWith_insert)]
227
217
]
228
218
]
229
219
]
@@ -334,18 +324,3 @@ insertIM xs m0 = foldl' (\m (k, v) -> IM.insert k v m) m0 xs
334
324
335
325
deleteIM :: [Int ] -> IM. IntMap Int -> IM. IntMap Int
336
326
deleteIM xs m0 = foldl' (\ m k -> IM. delete k m) m0 xs
337
-
338
- ------------------------------------------------------------------------
339
- -- * Reference implementations
340
-
341
- fromList_insert :: (Eq k , Hashable k ) => [(k , v )] -> HM. HashMap k v
342
- fromList_insert = foldl' (\ m (k, v) -> HM. insert k v m) HM. empty
343
- #if __GLASGOW_HASKELL__ >= 700
344
- {-# INLINABLE fromList_insert #-}
345
- #endif
346
-
347
- fromListWith_insert :: (Eq k , Hashable k ) => (v -> v -> v ) -> [(k , v )] -> HM. HashMap k v
348
- fromListWith_insert f = foldl' (\ m (k, v) -> HM. insertWith f k v m) HM. empty
349
- #if __GLASGOW_HASKELL__ >= 700
350
- {-# INLINABLE fromListWith_insert #-}
351
- #endif
0 commit comments