Masatake YAMATO <[EMAIL PROTECTED]> writes:

> >     (defun tla--buffers-rmap nil
> >       "Reverse mapping from buffers to types.
> >       ((buffer1 . type1) (buffer2 . type2)...)")
> Sorry. This should be defvar.
> 
> This is the patch. assoc list could be replicable with hashtable.
> 
> * looking for [EMAIL PROTECTED] to compare with
> * comparing to [EMAIL PROTECTED]
> 
>   M  lisp/xtla-core.el
>                                                                         
> 
> 
> * modified files
> 
> --- orig/lisp/xtla-core.el
> +++ mod/lisp/xtla-core.el
> @@ -106,17 +106,27 @@
>           (\"path3\" buffer4 \"original name of buffer4\")))
>  Used to keep track of all the tla related buffers.")
>  
> +(defvar tla--buffers-rmap nil
> +  "Reverse mapping from buffers to types.
> +  ((buffer1 . type1) (buffer2 . type2)...)")
> +
>  (defun tla--buffers-tree-remove (buffer)
>    "Remove BUFFER from the buffers tree."
> -    (dolist (type-cons tla--buffers-tree)
> +  (let ((type (car (assq buffer tla--buffers-rmap)))
> +        type-cons)
> +    (when type
> +      (setq tla--buffers-rmap (assq-delete-all buffer tla--buffers-rmap))
> +      (setq type-cons (assq type tla--buffers-tree))
>        (dolist (path-buffer (cdr type-cons))
>          (when (eq (cadr path-buffer) buffer)
> -          (setcdr type-cons (delete path-buffer (cdr type-cons)))))))
> +          (setcdr type-cons (delete path-buffer (cdr type-cons))))))))
>  
>  (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))
>      (if current-assoc
>          (setcdr current-assoc
>                  (cons (list path buffer (buffer-name buffer))
> 

Your patch looks fine.

One question remains:
Why do you think that tla--buffers-tree-remove is too slow?

Is it, because the code looks to inefficient - I agree here
Or are some operations too slow? How often is tla--buffers-tree-remove
called?


Stefan.


Reply via email to