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

gwern0 at gmail.com gwern0 at gmail.com
Mon Oct 15 19:54:28 EDT 2007

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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/x-darcs-patch
Size: 31384 bytes
Desc: A darcs patch for your repository!
Url : http://www.haskell.org/pipermail/xmonad/attachments/20071015/11087805/attachment-0001.bin

More information about the Xmonad mailing list