all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Ineffient code in tramp.el
@ 2005-06-06 12:16 Kim F. Storm
  2005-06-06 12:42 ` David Kastrup
  0 siblings, 1 reply; 2+ messages in thread
From: Kim F. Storm @ 2005-06-06 12:16 UTC (permalink / raw)
  Cc: emacs-devel


Tramp has this function:

(defun tramp-match-string-list (&optional string)
  "Returns list of all match strings.
That is, (list (match-string 0) (match-string 1) ...), according to the
number of matches."
  (let* ((nmatches (/ (length (match-data)) 2))
         (i (- nmatches 1))
         (res nil))
    (while (>= i 0)
      (setq res (cons (match-string i string) res))
      (setq i (- i 1)))
    res))


It is used in function tramp-wait-for-regexp only, and all uses of
that function only tests whether the return value is nil or non-nil.

So the above code seems like vast overkill to me :-)

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Ineffient code in tramp.el
  2005-06-06 12:16 Ineffient code in tramp.el Kim F. Storm
@ 2005-06-06 12:42 ` David Kastrup
  0 siblings, 0 replies; 2+ messages in thread
From: David Kastrup @ 2005-06-06 12:42 UTC (permalink / raw)
  Cc: kai.grossjohann, emacs-devel

storm@cua.dk (Kim F. Storm) writes:

> Tramp has this function:
>
> (defun tramp-match-string-list (&optional string)
>   "Returns list of all match strings.
> That is, (list (match-string 0) (match-string 1) ...), according to the
> number of matches."
>   (let* ((nmatches (/ (length (match-data)) 2))
>          (i (- nmatches 1))
>          (res nil))
>     (while (>= i 0)
>       (setq res (cons (match-string i string) res))
>       (setq i (- i 1)))
>     res))
>
>
> It is used in function tramp-wait-for-regexp only, and all uses of
> that function only tests whether the return value is nil or non-nil.
>
> So the above code seems like vast overkill to me :-)

In addition, (/ (length (match-data)) 2) creates a whole slew of
markers that slow down editing operations until the next garbage
collection.  You should rather use
(/ (length (match-data t)) 2)
if you really must.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-06-06 12:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-06 12:16 Ineffient code in tramp.el Kim F. Storm
2005-06-06 12:42 ` David Kastrup

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.