Only read from cache when necessary
This commit is contained in:
parent
b1a688fc2f
commit
2cedde3400
@ -198,7 +198,7 @@ fu! s:Close()
|
|||||||
sil! exe 'let &'.key.' = s:glb_'.key
|
sil! exe 'let &'.key.' = s:glb_'.key
|
||||||
en | endfo
|
en | endfo
|
||||||
if exists('s:glb_acd') | let &acd = s:glb_acd | en
|
if exists('s:glb_acd') | let &acd = s:glb_acd | en
|
||||||
let [g:ctrlp_lines, g:ctrlp_allfiles] = [[], []]
|
let g:ctrlp_lines = []
|
||||||
if s:winres[1] >= &lines && s:winres[2] == winnr('$')
|
if s:winres[1] >= &lines && s:winres[2] == winnr('$')
|
||||||
exe s:winres[0]
|
exe s:winres[0]
|
||||||
en
|
en
|
||||||
@ -233,9 +233,9 @@ fu! ctrlp#reset()
|
|||||||
endf
|
endf
|
||||||
" * Files {{{1
|
" * Files {{{1
|
||||||
fu! ctrlp#files()
|
fu! ctrlp#files()
|
||||||
let [cafile, g:ctrlp_allfiles] = [ctrlp#utils#cachefile(), []]
|
let cafile = ctrlp#utils#cachefile()
|
||||||
if g:ctrlp_newcache || !filereadable(cafile) || !s:caching
|
if g:ctrlp_newcache || !filereadable(cafile) || !s:caching
|
||||||
let lscmd = s:lsCmd()
|
let [lscmd, s:initcwd, g:ctrlp_allfiles] = [s:lsCmd(), s:dyncwd, []]
|
||||||
" Get the list of files
|
" Get the list of files
|
||||||
if empty(lscmd)
|
if empty(lscmd)
|
||||||
cal s:GlobPath(s:dyncwd, 0)
|
cal s:GlobPath(s:dyncwd, 0)
|
||||||
@ -246,15 +246,16 @@ fu! ctrlp#files()
|
|||||||
en
|
en
|
||||||
" Remove base directory
|
" Remove base directory
|
||||||
cal ctrlp#rmbasedir(g:ctrlp_allfiles)
|
cal ctrlp#rmbasedir(g:ctrlp_allfiles)
|
||||||
let read_cache = 0
|
|
||||||
if len(g:ctrlp_allfiles) <= s:compare_lim
|
if len(g:ctrlp_allfiles) <= s:compare_lim
|
||||||
cal sort(g:ctrlp_allfiles, 'ctrlp#complen')
|
cal sort(g:ctrlp_allfiles, 'ctrlp#complen')
|
||||||
en
|
en
|
||||||
|
cal s:writecache(cafile)
|
||||||
el
|
el
|
||||||
let g:ctrlp_allfiles = ctrlp#utils#readfile(cafile)
|
if !( exists('s:initcwd') && s:initcwd == s:dyncwd )
|
||||||
let read_cache = 1
|
let s:initcwd = s:dyncwd
|
||||||
|
let g:ctrlp_allfiles = ctrlp#utils#readfile(cafile)
|
||||||
|
en
|
||||||
en
|
en
|
||||||
cal s:writecache(read_cache, cafile)
|
|
||||||
retu g:ctrlp_allfiles
|
retu g:ctrlp_allfiles
|
||||||
endf
|
endf
|
||||||
|
|
||||||
@ -1010,7 +1011,7 @@ fu! s:mixedsort(s1, s2)
|
|||||||
unl! s:mrbs
|
unl! s:mrbs
|
||||||
retu cln + ctm * mp_1 + cfn * mp_2 + par * mp_3 + cml * mp_4
|
retu cln + ctm * mp_1 + cfn * mp_2 + par * mp_3 + cml * mp_4
|
||||||
en
|
en
|
||||||
let [mp_1, mp_2, mp_3, mp_4] = s:multiplier(cfn, par, cml, 0)
|
let [mp_1, mp_2, mp_3, mp_4] = s:multipliers(cfn, par, cml, 0)
|
||||||
retu cln + cfn * mp_1 + par * mp_2 + cml * mp_3
|
retu cln + cfn * mp_1 + par * mp_2 + cml * mp_3
|
||||||
en
|
en
|
||||||
retu cln + cml * 2
|
retu cln + cml * 2
|
||||||
@ -1545,11 +1546,12 @@ fu! s:mmode()
|
|||||||
retu matchmodes[s:mfunc]
|
retu matchmodes[s:mfunc]
|
||||||
endf
|
endf
|
||||||
" Cache {{{2
|
" Cache {{{2
|
||||||
fu! s:writecache(read_cache, cache_file)
|
fu! s:writecache(cache_file)
|
||||||
if !a:read_cache && ( ( g:ctrlp_newcache || !filereadable(a:cache_file) )
|
if ( g:ctrlp_newcache || !filereadable(a:cache_file) ) && s:caching
|
||||||
\ && s:caching || len(g:ctrlp_allfiles) > s:nocache_lim )
|
\ || len(g:ctrlp_allfiles) > s:nocache_lim
|
||||||
if len(g:ctrlp_allfiles) > s:nocache_lim | let s:caching = 1 | en
|
if len(g:ctrlp_allfiles) > s:nocache_lim | let s:caching = 1 | en
|
||||||
cal ctrlp#utils#writecache(g:ctrlp_allfiles)
|
cal ctrlp#utils#writecache(g:ctrlp_allfiles)
|
||||||
|
let g:ctrlp_newcache = 0
|
||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
|
|
||||||
@ -1567,7 +1569,7 @@ fu! s:insertcache(str)
|
|||||||
endfo
|
endfo
|
||||||
en
|
en
|
||||||
cal insert(data, str, pos)
|
cal insert(data, str, pos)
|
||||||
cal s:writecache(0, ctrlp#utils#cachefile())
|
cal s:writecache(ctrlp#utils#cachefile())
|
||||||
endf
|
endf
|
||||||
" Extensions {{{2
|
" Extensions {{{2
|
||||||
fu! s:mtype()
|
fu! s:mtype()
|
||||||
|
@ -54,20 +54,19 @@ fu! ctrlp#dir#init(...)
|
|||||||
let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().s:dir_var['sname']
|
let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().s:dir_var['sname']
|
||||||
let cafile = cadir.ctrlp#utils#lash().ctrlp#utils#cachefile(s:dir_var['sname'])
|
let cafile = cadir.ctrlp#utils#lash().ctrlp#utils#cachefile(s:dir_var['sname'])
|
||||||
if g:ctrlp_newdir || !filereadable(cafile)
|
if g:ctrlp_newdir || !filereadable(cafile)
|
||||||
let g:ctrlp_alldirs = []
|
let [s:initcwd, g:ctrlp_alldirs] = [s:cwd, []]
|
||||||
cal s:globdirs(s:cwd, 0)
|
cal s:globdirs(s:cwd, 0)
|
||||||
cal ctrlp#rmbasedir(g:ctrlp_alldirs)
|
cal ctrlp#rmbasedir(g:ctrlp_alldirs)
|
||||||
let read_cache = 0
|
|
||||||
if len(g:ctrlp_alldirs) <= s:compare_lim
|
if len(g:ctrlp_alldirs) <= s:compare_lim
|
||||||
cal sort(g:ctrlp_alldirs, 'ctrlp#complen')
|
cal sort(g:ctrlp_alldirs, 'ctrlp#complen')
|
||||||
en
|
en
|
||||||
el
|
|
||||||
let g:ctrlp_alldirs = ctrlp#utils#readfile(cafile)
|
|
||||||
let read_cache = 1
|
|
||||||
en
|
|
||||||
if !read_cache
|
|
||||||
cal ctrlp#utils#writecache(g:ctrlp_alldirs, cadir, cafile)
|
cal ctrlp#utils#writecache(g:ctrlp_alldirs, cadir, cafile)
|
||||||
let g:ctrlp_newdir = 0
|
let g:ctrlp_newdir = 0
|
||||||
|
el
|
||||||
|
if !( exists('s:initcwd') && s:initcwd == s:cwd )
|
||||||
|
let s:initcwd = s:cwd
|
||||||
|
let g:ctrlp_alldirs = ctrlp#utils#readfile(cafile)
|
||||||
|
en
|
||||||
en
|
en
|
||||||
retu g:ctrlp_alldirs
|
retu g:ctrlp_alldirs
|
||||||
endf
|
endf
|
||||||
|
@ -38,7 +38,7 @@ fu! s:getnewmix(cwd, clim)
|
|||||||
cal ctrlp#mrufiles#refresh('raw')
|
cal ctrlp#mrufiles#refresh('raw')
|
||||||
let g:ctrlp_newcache = 1
|
let g:ctrlp_newcache = 1
|
||||||
en
|
en
|
||||||
let g:ctrlp_lines = ctrlp#files()
|
let g:ctrlp_lines = copy(ctrlp#files())
|
||||||
cal ctrlp#progress('Mixing...')
|
cal ctrlp#progress('Mixing...')
|
||||||
let mrufs = ctrlp#mrufiles#list('raw')
|
let mrufs = ctrlp#mrufiles#list('raw')
|
||||||
if exists('+ssl') && &ssl
|
if exists('+ssl') && &ssl
|
||||||
|
@ -33,9 +33,9 @@ fu! ctrlp#utils#cachedir()
|
|||||||
endf
|
endf
|
||||||
|
|
||||||
fu! ctrlp#utils#cachefile(...)
|
fu! ctrlp#utils#cachefile(...)
|
||||||
let tail = a:0 ? '.'.a:1 : ''
|
let [tail, dir] = [a:0 == 1 ? '.'.a:1 : '', a:0 == 2 ? a:1 : getcwd()]
|
||||||
let cache_file = substitute(getcwd(), '\([\/]\|^\a\zs:\)', '%', 'g').tail.'.txt'
|
let cache_file = substitute(dir, '\([\/]\|^\a\zs:\)', '%', 'g').tail.'.txt'
|
||||||
retu a:0 ? cache_file : s:cache_dir.s:lash(s:cache_dir).cache_file
|
retu a:0 == 1 ? cache_file : s:cache_dir.s:lash(s:cache_dir).cache_file
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! ctrlp#utils#readfile(file)
|
fu! ctrlp#utils#readfile(file)
|
||||||
@ -60,9 +60,6 @@ endf
|
|||||||
fu! ctrlp#utils#writecache(lines, ...)
|
fu! ctrlp#utils#writecache(lines, ...)
|
||||||
if isdirectory(ctrlp#utils#mkdir(a:0 ? a:1 : s:cache_dir))
|
if isdirectory(ctrlp#utils#mkdir(a:0 ? a:1 : s:cache_dir))
|
||||||
sil! cal writefile(a:lines, a:0 >= 2 ? a:2 : ctrlp#utils#cachefile())
|
sil! cal writefile(a:lines, a:0 >= 2 ? a:2 : ctrlp#utils#cachefile())
|
||||||
if !a:0
|
|
||||||
let g:ctrlp_newcache = 0
|
|
||||||
en
|
|
||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user