-
Notifications
You must be signed in to change notification settings - Fork 186
Description
Currently, we try to be very efficient about lists that ascend from the start for most of their length. This seems a tad specific. I suspect what we'd really like to use is an algorithm more like that of Data.List.sort. That is, break up the input into ascending and descending segments, convert each segment, and use union to join the segments together. Unfortunately, the current code is not structured in a way that makes this terribly easy.
Another (less serious) problem is that fromAscListWithKey and fromDescListWithKey preprocess their input lists to squash duplicates. When there aren't any duplicates, this allocates a bunch of short-lived conses. It would be nice to find a way to avoid this, but it's probably not terribly important. I made a brief attempt, but it got horrible pretty quickly.
Another (more serious?) problem is that (Fixed in #332)Data.Map.fromAscList is defined in terms of fromAscListWithKey, which in the lazy case seems rather likely to produce an avoidable space leak.