From 26983f1921bd0e14769059abab94e02073345557 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 9 Jun 2008 21:18:30 +1200 Subject: [PATCH] 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... --- plugin/NERD_tree.vim | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index d5e14aa..028b1f3 100644 --- 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