For tight inner loops a double indirection of Dictionary (pointer to MutVar# + pointer to Dictionary_) might have a significant performance cost. I'd like to have something like
insert_ :: (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k)
=> Dictionary_ (PrimState m) ks k vs v -> k -> v -> m Bool
If Dictionary_ is sufficient to insert without resize, return True. Otherwise return False, so that a user can wrap their Dictionary_ into DRef and MutVar, pass to a usual insert, which will perform all necessary rituals to grow sizes, and extract naked Dictionary_ back.
(A specialized API to resize Dictionary_ explicitly would be even better, but that's a bonus).
For tight inner loops a double indirection of
Dictionary
(pointer toMutVar#
+ pointer toDictionary_
) might have a significant performance cost. I'd like to have something likeIf
Dictionary_
is sufficient to insert without resize, returnTrue
. Otherwise returnFalse
, so that a user can wrap theirDictionary_
intoDRef
andMutVar
, pass to a usualinsert
, which will perform all necessary rituals to grow sizes, and extract nakedDictionary_
back.(A specialized API to resize
Dictionary_
explicitly would be even better, but that's a bonus).