haskell / haskell/containers

mergeWithKey' may be too general for its own good

未关闭
#227 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
IntMap performance
主要语言
Haskell
星标
355
派生
194
平均合并
3 天 4 小时
30 天内合并 PR
4

描述

It's cute that `mergeWithKey'` can implement so many different things, but there's a performance cost. Different operations necessitate different `Nil` checking, which `mergeWithKey'` has no way to deal with. The fact that the functions passed to it are often partial is also a bit disturbing, suggesting there may be a better approach. Having the combining function take maps instead of keys and values to enhance sharing sounds very reasonable until you see that it's actually only called for `Tip` trees. So the sharing is probably significant, but not earth-shattering. Using something like the evil pointer equality check could potentially have a much bigger impact, I imagine. Short of that, the partial functions could be avoided by passing both the `Tip` and its contents in separate arguments, although that's kind of ugly.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。