Speed up sortChildren() by using sorting token

This improves the sorting functions from 12 seconds to 0.66 seconds for
~4000 objects
This commit is contained in:
Vincent Tsang
2015-05-09 22:38:16 +08:00
parent a87b1bf3c5
commit 57d5bd7731
2 changed files with 29 additions and 1 deletions

View File

@@ -34,6 +34,17 @@ function! nerdtree#compareNodes(n1, n2)
return a:n1.path.compareTo(a:n2.path)
endfunction
"FUNCTION: nerdtree#compareNodesBySortingToken(n1, n2) {{{2
function! nerdtree#compareNodesBySortingToken(n1, n2)
if a:n1.sorting_token < a:n2.sorting_token
return -1
elseif a:n1.sorting_token > a:n2.sorting_token
return 1
else
return 0
endif
endfunction
" FUNCTION: nerdtree#deprecated(func, [msg]) {{{2
" Issue a deprecation warning for a:func. If a second arg is given, use this
" as the deprecation message