On Mar 25, 2014 11:41 PM, "Charles E Campbell" <[email protected]> wrote: > > LCD 47 wrote: >> >> On 19 March 2014, Cade Forester <[email protected]> wrote: >>>> >>>> Looks like you made a copy of f_sort() and modified it a bit. That's a >>>> >>>> lot of duplicate code. Better move the common stuff into a function >>>> >>>> that's used by both sort() and sortuniq(). >>> >>> Fixed >> >> How about separating it from sort()? That is, an uniq() function >> that would remove duplicates from an already sorted list (results would >> be undefined if the input list is not sorted). That would be consistent >> with how uniq(1) works on UNIX. >> > I'm not convinced that it should even be in the vim source. (ducking spitballs now) The only reason I see for it is to support Windows, as it is command-line tool poor. Otherwise, ... > Why not use a plugin? Why not use system() (and macos's or linux's uniq)? Going through a list to do uniq should be an O(n) action. Sorting is O(n)log(n) (or O(n^2) for some algorithms), and so speed is more important. > > This process logically would re-invent lots of tools and embed them in vim (admittedly, uniq is likely to be a small one). However, there's lots of tools that Windows lacks that "would be nice" to have -- but should vim have it?
It is convenience-for-maintainability trade-off. One of the reasons I like python is its standard library: for 90% of needs I use just it. And, hell, this is very convenient. But most likely hard to maintain. Coding this in C is only an optimization: if you have lots of VimL code it easily starts to become too slow. This does not matter how sort is compared to uniq: if you have thousands iterations you take a code generator that removes whitespaces, truncates command names and joins a sequence of Ex commands into a single one (though only the last was beneficial enough, first two only won very few ms, but were much easier to implement) and hope it is enough. I would not say I need fast uniq() though: I never needed uniq() not in shell at all. But others may need. > > Regards, > Chip Campbell > > > > -- > -- > You received this message from the "vim_dev" maillist. > Do not top-post! Type your reply below the text you are replying to. > For more information, visit http://www.vim.org/maillist.php > > --- You received this message because you are subscribed to the Google Groups "vim_dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
