|
1 | 1 | " Vim script |
2 | 2 | " Author: Peter Odding <peter@peterodding.com> |
3 | | -" Last Change: April 18, 2013 |
| 3 | +" Last Change: April 19, 2013 |
4 | 4 | " URL: http://peterodding.com/code/vim/easytags/ |
5 | 5 |
|
6 | | -let g:xolox#easytags#version = '2.8.2' |
| 6 | +let g:xolox#easytags#version = '2.9' |
7 | 7 |
|
8 | 8 | " Public interface through (automatic) commands. {{{1 |
9 | 9 |
|
@@ -204,38 +204,6 @@ function! s:prep_cmdline(cfile, tagsfile, firstrun, arguments, context) " {{{3 |
204 | 204 | return have_args ? join(cmdline) : '' |
205 | 205 | endfunction |
206 | 206 |
|
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 | | - |
239 | 207 | function! s:run_ctags(starttime, cfile, tagsfile, firstrun, cmdline) " {{{3 |
240 | 208 | let lines = [] |
241 | 209 | let has_updates = 1 |
@@ -266,6 +234,44 @@ function! s:run_ctags(starttime, cfile, tagsfile, firstrun, cmdline) " {{{3 |
266 | 234 | return [xolox#easytags#parse_entries(lines), has_updates] |
267 | 235 | endfunction |
268 | 236 |
|
| 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 | + |
269 | 275 | function! s:filter_merge_tags(filter_tags, tagsfile, output, context) " {{{3 |
270 | 276 | let [headers, entries] = xolox#easytags#read_tagsfile(a:tagsfile) |
271 | 277 | let filters = [] |
|
0 commit comments