Optimize doom-visible-buffers

Walking the window list is almost always faster than walking the buffer
list.
This commit is contained in:
Henrik Lissner 2019-10-20 09:26:55 -04:00
parent bdd9d91f72
commit c109acd6fd
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -177,9 +177,9 @@ If DERIVED-P, test with `derived-mode-p', otherwise use `eq'."
;;;###autoload
(defun doom-visible-buffers (&optional buffer-list)
"Return a list of visible buffers (i.e. not buried)."
(cl-loop for buf in (or buffer-list (doom-buffer-list))
when (get-buffer-window buf)
collect buf))
(if buffer-list
(cl-remove-if-not #'get-buffer-window buffer-list)
(delete-dups (mapcar #'window-buffer (window-list)))))
;;;###autoload
(defun doom-buried-buffers (&optional buffer-list)