2010/7/28 Dominique Pellé <dominique.pe...@gmail.com>: > * I could also reuse remove_duplicates() but it has a slightly > different behavior since it calls fnamecmp() instead of > STRCMP() to check for dupes. I wonder whether that's > desirable here. I think it's better to use STRCMP() in my case.
In that case maybe remove_duplicate can be modified to accept a second argument which is a function pointer to be used as the string comparator. > Remark about remove_duplicate() in misc1.c: It'd be slightly better > if remove_duplicates(...) looped backward (as in my function) to > avoid doing more moves than necessary when there are dupes (and > to compare with 0 in exit condition which is also cheaper). Say you > have to remove dupes in this pathological case: > "x", "x", "x", ... "x", "x" (n times) > remove_duplicate() as currently implemented would do (n-1)*n/2 > moves (that's O(n^2)) whereas when looping backward() as in my > function, it does 0 moves. Looping backward will always do less > moves since it avoids moving duplicates already removed. That is indeed the better implementation. I didn't notice the difference the first time I looked at your loop. nazri. -- 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