[Xmonad] darcs patch: ShellPrompt.hs: a quick optimization of nub

Spencer Janssen sjanssen at cse.unl.edu
Mon Oct 15 20:51:21 EDT 2007

On Monday 15 October 2007 18:54:28 gwern0 at gmail.com wrote:
> Mon Oct 15 19:48:50 EDT 2007  gwern0 at gmail.com
>   * ShellPrompt.hs: a quick optimization of nub
>   I saw some complaints about ShellPrompt being slow - and noticed it
> myself - and it seems ShellPrompt uses 'nub' in an awkward place to
> uniquefy input. Nub doesn't perform well on long lists, but I once ran into
> a similar problem and the suggested solution was something clever: convert
> to a Set and then back to a List. Sets can't have duplicate entries, and
> they uniquefy faster than nub. The price is that the output is not sorted
> the same as nub's output would be, but this is OK because the output of
> (toList . fromList) is immediately passed to 'sort' - which should then
> produce the same output for both versions. I haven't really tested this but
> on long directories this should help.


More information about the Xmonad mailing list