Skip to content

Commit 07437cf

Browse files
committed
Minor changes to pull request #43 on GitHub (thank you Ingo :-)
The pull request: #43
1 parent 79d23f9 commit 07437cf

File tree

1 file changed

+40
-34
lines changed

1 file changed

+40
-34
lines changed

autoload/xolox/easytags.vim

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
" Vim script
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: April 18, 2013
3+
" Last Change: April 19, 2013
44
" URL: http://peterodding.com/code/vim/easytags/
55

6-
let g:xolox#easytags#version = '2.8.2'
6+
let g:xolox#easytags#version = '2.9'
77

88
" Public interface through (automatic) commands. {{{1
99

@@ -204,38 +204,6 @@ function! s:prep_cmdline(cfile, tagsfile, firstrun, arguments, context) " {{{3
204204
return have_args ? join(cmdline) : ''
205205
endfunction
206206

207-
if exists('*sha256')
208-
function! s:get_fingerprint(cfile, output)
209-
return sha256(a:output)
210-
endfunction
211-
else
212-
function! s:get_fingerprint(cfile, output)
213-
" Don't want to re-implement a costly hashing function in Vimscript. Just
214-
" handle files that never had any tags.
215-
if empty(a:output)
216-
return get(s:fingerprints, a:cfile, 1)
217-
else
218-
return ''
219-
endif
220-
endfunction
221-
endif
222-
223-
let s:fingerprints = {}
224-
function! s:has_updates(cfile, output)
225-
if empty(a:cfile)
226-
" The cache doesn't work when tags aren't created for the current file.
227-
return 1
228-
endif
229-
230-
let fingerprint = s:get_fingerprint(a:cfile, a:output)
231-
if ! empty(fingerprint) && get(s:fingerprints, a:cfile, '') ==# fingerprint
232-
return 0
233-
endif
234-
235-
let s:fingerprints[a:cfile] = fingerprint
236-
return 1
237-
endfunction
238-
239207
function! s:run_ctags(starttime, cfile, tagsfile, firstrun, cmdline) " {{{3
240208
let lines = []
241209
let has_updates = 1
@@ -266,6 +234,44 @@ function! s:run_ctags(starttime, cfile, tagsfile, firstrun, cmdline) " {{{3
266234
return [xolox#easytags#parse_entries(lines), has_updates]
267235
endfunction
268236

237+
" Vim 7.3 now has the sha256() function. We use it below to recognize when the
238+
" tags haven't changed from the last time we ran Exuberant Ctags on a file; in
239+
" this case the tags file doesn't have to be written to disk which makes the
240+
" plug-in much faster for a very common case.
241+
242+
let s:fingerprints = {}
243+
244+
function! s:has_updates(cfile, output)
245+
if empty(a:cfile)
246+
" The cache doesn't work when tags aren't created for the current file.
247+
return 1
248+
endif
249+
let fingerprint = s:get_fingerprint(a:cfile, a:output)
250+
call xolox#misc#msg#debug("easytags.vim %s: Fingerprint of tags in %s is %s.", g:xolox#easytags#version, a:cfile, string(fingerprint))
251+
if !empty(fingerprint) && get(s:fingerprints, a:cfile, '') ==# fingerprint
252+
call xolox#misc#msg#debug("easytags.vim %s: The fingerprint didn't change! We can take a shortcut :-)", g:xolox#easytags#version)
253+
return 0
254+
endif
255+
let s:fingerprints[a:cfile] = fingerprint
256+
return 1
257+
endfunction
258+
259+
if exists('*sha256')
260+
function! s:get_fingerprint(cfile, output)
261+
return sha256(a:output)
262+
endfunction
263+
else
264+
function! s:get_fingerprint(cfile, output)
265+
" Don't want to re-implement a costly hashing function in Vimscript. Just
266+
" handle files that never had any tags.
267+
if empty(a:output)
268+
return get(s:fingerprints, a:cfile, 1)
269+
else
270+
return ''
271+
endif
272+
endfunction
273+
endif
274+
269275
function! s:filter_merge_tags(filter_tags, tagsfile, output, context) " {{{3
270276
let [headers, entries] = xolox#easytags#read_tagsfile(a:tagsfile)
271277
let filters = []

0 commit comments

Comments
 (0)