nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit 26983f1921bd0e14769059abab94e02073345557
parent 1571274aec50b1c411d157afef2d1d63e94262ff
Author: Martin Grenfell <martin_grenfell@msn.com>
Date:   Mon,  9 Jun 2008 21:18:30 +1200

make oPath cache the marks associated with it

This is mainly for performance reasons. Calculating the marks anew
everytime oPath#MarkNames() is called greatly increases the rendering
time of the tree. It trippled it for just a handful of marks...

Diffstat:
Mplugin/NERD_tree.vim | 24++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim
@@ -812,6 +812,17 @@ endfunction
 "============================================================
 let s:oPath = {}
 let oPath = s:oPath
+"FUNCTION: oPath.CacheMarkNames() {{{3
+function! s:oPath.CacheMarkNames() dict
+    let self.markNames = []
+    let marks = s:GetMarks()
+    for k in keys(marks)
+        if marks[k].Equals(self)
+            call add(self.markNames, k)
+        endif
+    endfor
+    return self.markNames
+endfunction
 "FUNCTION: oPath.ChangeToDir() {{{3
 function! s:oPath.ChangeToDir() dict
     let dir = self.StrForCd()
@@ -1110,14 +1121,10 @@ endfunction
 
 "FUNCTION: oPath.MarkNames() {{{3
 function! s:oPath.MarkNames() dict
-    let toReturn = []
-    let marks = s:GetMarks()
-    for k in keys(marks)
-        if marks[k].Equals(self)
-            call add(toReturn, k)
-        endif
-    endfor
-    return toReturn
+    if !exists("self.markNames")
+        call self.CacheMarkNames()
+    endif
+    return self.markNames
 endfunction
 "FUNCTION: oPath.New() {{{3
 "
@@ -1179,6 +1186,7 @@ endfunction
 "FUNCTION: oPath.Refresh() {{{3
 function! s:oPath.Refresh() dict
     call self.ReadInfoFromDisk(self.StrForOS(0))
+    call self.CacheMarkNames()
 endfunction
 
 "FUNCTION: oPath.Rename() {{{3