ghc.compiler.GHC.Cmm.Switch.restrictMap could be more efficient
The first split
restrictMap :: (Integer,Integer) -> M.Map Integer b -> M.Map Integer b restrictMap (lo,hi) m = mid where (_, mid_hi) = M.split (lo-1) m (mid, _) = M.split (hi+1) mid_hi
might do useless work when the result map is small. See discussion at https://github.com/haskell/containers/pull/803#issuecomment-1062968905
But .. if it did not show up in profiles before, then perhaps it does not need to be fixed. Anyway I thought I'd mention it here.