emacs-devel
[Top][All Lists]
Advanced

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

Re: Inefficient code in reftex-index.el


From: David Kastrup
Subject: Re: Inefficient code in reftex-index.el
Date: Fri, 10 Jun 2005 16:13:05 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Richard Stallman <address@hidden> writes:

>     Certainly cleaner than the straw man you are trying to put up, no
>     question about that.
>
> It's not a straw man.  It's what I'd expect most such cases to do.
>
> If it is very important to optimize your code, we could add a
> function match-count to do so.  But is it really that important to
> optimize?

I think that if one has the situation of a number of strings and
corresponding actions in a data structure, and one wants to repeatedly
search for the next occurence of any matching string, and then do the
recorded corresponding action, this would be a typical situation where
match-count would be convenient.

grepping through the Emacs tree suggests that this usage is not
common, however.  But I did see several occasions where match-count
seemed appropriate as a loop limit for running through possible
matched groups after a match.

There is also the following in tramp.el:
/home/tmp/emacs/lisp/net/tramp.el:6450:  (let* ((nmatches (/ (length 
(match-data)) 2))
/home/tmp/emacs/lisp/net/tramp.el:6793:    (setq len (/ (length (match-data t)) 
2))

In particular the former usage suffers from the "trailing markers"
slowdown.  While it is something that should be fixed here, it would
seem that the availability of match-count would have prevented this
particular abuse.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum




reply via email to

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