tla--buffers-tree-remove is slow.
I feel this is a bug.
(defun tla--buffers-tree-remove (buffer)
"Remove BUFFER from the buffers tree."
(dolist (type-cons tla--buffers-tree)
(dolist (path-buffer (cdr type-cons))
(when (eq (cadr path-buffer) buffer)
(setcdr type-cons (delete path-buffer (cdr type-cons)))))))
ELISP> (apply '+ (mapcar (lambda (elt) (length elt)) tla--buffers-tree))
58
Is there possibility that a buffer appearers multiple place in
`tla--buffers-tree'?
If not(I hope so), we can introduce
(defun tla--buffers-rmap nil
"Reverse mapping from buffers to types.
((buffer1 . type1) (buffer2 . type2)...)")
(defun tla--buffers-tree-add (type path buffer)
"Add a buffer of TYPE visiting PATH to the buffers tree.
BUFFER should be the buffer to add."
(let ((current-assoc (assoc type tla--buffers-tree)))
(setq tla--buffers-rmap (cons (cons buffer type)
tla--buffers-rmap))
`tla--buffers-rmap' can help increase the speed to scan the tree.
Buffer local variables may not help. They are killed by
`kill-all-local-variables'.
Masatake YAMATO