aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Kroon <bart@tarmack.eu>2011-09-07 22:22:05 +0200
committerBart Kroon <bart@tarmack.eu>2011-09-07 22:22:05 +0200
commit9cabfbd1d09b41b7b78ebf57a42957ba87ff136f (patch)
treed0309f4f805dba1592ea378a55a025422bf09c4c
parent2cfd5153a2cd25f5513a9c6aa72196691dd74d19 (diff)
downloadvim-easytags-9cabfbd1d09b41b7b78ebf57a42957ba87ff136f.tar.gz
Made list#unique about 5 times faster using filter().
-rw-r--r--list.vim15
1 files changed, 3 insertions, 12 deletions
diff --git a/list.vim b/list.vim
index 44d6b20..ee243d4 100644
--- a/list.vim
+++ b/list.vim
@@ -6,18 +6,9 @@
" Remove duplicate values from {list} in-place (preserves order).
function! xolox#misc#list#unique(list)
- let index = 0
- while index < len(a:list)
- let value = a:list[index]
- let match = index(a:list, value, index+1)
- if match >= 0
- call remove(a:list, match)
- else
- let index += 1
- endif
- unlet value
- endwhile
- return a:list
+ call reverse(a:list)
+ call filter(a:list, 'count(a:list, v:val) == 1')
+ return reverse(a:list)
endfunction
" Binary insertion (more efficient than calling sort() after each insertion).