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...
This commit is contained in:
Martin Grenfell 2008-06-09 21:18:30 +12:00
parent 1571274aec
commit 26983f1921

View File

@ -812,6 +812,17 @@ endfunction
"============================================================ "============================================================
let s:oPath = {} let s:oPath = {}
let oPath = 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: oPath.ChangeToDir() {{{3
function! s:oPath.ChangeToDir() dict function! s:oPath.ChangeToDir() dict
let dir = self.StrForCd() let dir = self.StrForCd()
@ -1110,14 +1121,10 @@ endfunction
"FUNCTION: oPath.MarkNames() {{{3 "FUNCTION: oPath.MarkNames() {{{3
function! s:oPath.MarkNames() dict function! s:oPath.MarkNames() dict
let toReturn = [] if !exists("self.markNames")
let marks = s:GetMarks() call self.CacheMarkNames()
for k in keys(marks) endif
if marks[k].Equals(self) return self.markNames
call add(toReturn, k)
endif
endfor
return toReturn
endfunction endfunction
"FUNCTION: oPath.New() {{{3 "FUNCTION: oPath.New() {{{3
" "
@ -1179,6 +1186,7 @@ endfunction
"FUNCTION: oPath.Refresh() {{{3 "FUNCTION: oPath.Refresh() {{{3
function! s:oPath.Refresh() dict function! s:oPath.Refresh() dict
call self.ReadInfoFromDisk(self.StrForOS(0)) call self.ReadInfoFromDisk(self.StrForOS(0))
call self.CacheMarkNames()
endfunction endfunction
"FUNCTION: oPath.Rename() {{{3 "FUNCTION: oPath.Rename() {{{3