[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: find-file-noselect needs save-match-data
From: |
David Kastrup |
Subject: |
Re: find-file-noselect needs save-match-data |
Date: |
Thu, 14 Jun 2007 19:18:25 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) |
Richard Stallman <address@hidden> writes:
> > Anyway, such a function should likely _return_ the corresponding
> > match-data (rather than setting a global variable to it), and things
> > like match-beginning should optionally take an argument for this
> > particular match-data.
>
> Then what's the advantage compared to using save-match-data?
>
> This function would be simpler, and probably noticeably faster, than
>
> (save-match-data
> (string-match X Y)
> (match-data))
>
> You have a valid point that this function would be somewhat
> slower than a similar function which returned only the position
> of the start of the match. I am not sure whether this speed
> difference is significant. Would someone like to try
> implementing those two functions, and see how they compare
> in speed to the expression above?
I think we have the problem that
a) save-match-data is a Lisp macro using (match-data), and
b) match-data constructs a very expensive data structure: it takes
quite a bit of consing, the default is to get markers, and accessing
any piece of match data is O(n) instead of O(1).
The basic global match-data structure is an array. Maybe we should
make save-match-data a cheap C operation. Another possibility for an
(incompatible) API change would be that save-match-data _clears_ the
match-data. That way, nested calls of save-match-data become cheap
since the inner levels don't need to allocate anything.
Once save-match-data becomes cheap (and nested calls very cheap), one
can propose that, as a rule, non-interactive functions should leave
the match-data alone.
All of the proposals of when to call and when not to call
save-match-data revolve around the problem that save-match-data is an
expensive operation. If we get rid of that problem, we don't need to
weigh advantages and disadvantages that much.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
- Re: find-file-noselect needs save-match-data, (continued)
- Re: find-file-noselect needs save-match-data, Herbert Euler, 2007/06/14
- Re: find-file-noselect needs save-match-data, Richard Stallman, 2007/06/15
- Re: find-file-noselect needs save-match-data, Richard Stallman, 2007/06/15
- Re: find-file-noselect needs save-match-data, martin rudalics, 2007/06/14
- Re: find-file-noselect needs save-match-data, Richard Stallman, 2007/06/15
- Re: find-file-noselect needs save-match-data, Stefan Monnier, 2007/06/15
- Re: find-file-noselect needs save-match-data, Richard Stallman, 2007/06/15
- Re: find-file-noselect needs save-match-data, Juri Linkov, 2007/06/17
- Re: find-file-noselect needs save-match-data, Lennart Borgman (gmail), 2007/06/17
- Re: find-file-noselect needs save-match-data, Richard Stallman, 2007/06/14
- Re: find-file-noselect needs save-match-data,
David Kastrup <=
- Re: find-file-noselect needs save-match-data, Richard Stallman, 2007/06/15
- Re: find-file-noselect needs save-match-data, Stefan Monnier, 2007/06/15
- Re: find-file-noselect needs save-match-data, Miles Bader, 2007/06/13
- Re: find-file-noselect needs save-match-data, Stefan Monnier, 2007/06/13
- Re: find-file-noselect needs save-match-data, martin rudalics, 2007/06/14
- Re: find-file-noselect needs save-match-data, Richard Stallman, 2007/06/14
- Re: find-file-noselect needs save-match-data, Stefan Monnier, 2007/06/14
- Re: find-file-noselect needs save-match-data, martin rudalics, 2007/06/15
- Re: find-file-noselect needs save-match-data, Stefan Monnier, 2007/06/15
- Re: find-file-noselect needs save-match-data, Herbert Euler, 2007/06/15