Просмотр исходного кода

Defer calculating buffer details until we know the user wants them.

Users who don't want to see unlisted buffers shouldn't have to pay for
the expensive work of calculating buffer details for unlisted buffers,
only to have that information ignored.  Calculate an unlisted buffer's
details only after we know the user wants to view them.
Michael Henry 10 месяцев назад
Родитель
Сommit
de92b107ca
1 измененных файлов с 9 добавлено и 2 удалено
  1. 9 2
      plugin/bufexplorer.vim

+ 9 - 2
plugin/bufexplorer.vim

@@ -740,8 +740,6 @@ function! s:GetBufferInfo(bufnr)
         " filename with an embedded '"' is present.
         let buf = {"attributes": bits[0], "line": substitute(bits[-1], '\s*', '', '')}
         let buf._bufnr = str2nr(buf.attributes)
-        call s:CalculateBufferDetails(buf)
-
         let all[buf._bufnr] = buf
     endfor
 
@@ -754,12 +752,21 @@ function! s:BuildBufferList()
 
     " Loop through every buffer.
     for buf in values(s:raw_buffer_listing)
+        " `buf.attributes` must exist, but we defer the expensive work of
+        " calculating other buffer details (e.g., `buf.fullname`) until we know
+        " the user wants to view this buffer.
+
         " Skip unlisted buffers if we are not to show them.
         if !g:bufExplorerShowUnlisted && buf.attributes =~ "u"
             " Skip unlisted buffers if we are not to show them.
             continue
         endif
 
+        " Ensure buffer details are computed for this buffer.
+        if !has_key(buf, 'fullname')
+            call s:CalculateBufferDetails(buf)
+        endif
+
         " Skip 'No Name' buffers if we are not to show them.
         if g:bufExplorerShowNoName == 0 && buf.hasNoName
             continue