浏览代码

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 月之前
父节点
当前提交
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