emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ineffient code in tramp.el


From: David Kastrup
Subject: Re: Ineffient code in tramp.el
Date: Mon, 06 Jun 2005 14:42:01 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

address@hidden (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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]