[Top][All Lists]

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

Re: find-file-noselect needs save-match-data

From: Stefan Monnier
Subject: Re: find-file-noselect needs save-match-data
Date: Wed, 06 Jun 2007 08:17:39 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

> ... like when you put a function calling `find-file-noselect' or
> `file-truename' on a sensitive hook.  You may have to look at the code
> of each function on the entire call tree to detect whether one of them
> might change match-data.  Since hardly anyone ever does that we'll have
> to live with spurious, very hard-to-detect bugs clobbering match-data.
> From the caller's point of view it's also hard to conceive why, for
> example, the simpler `file-chase-links' does save match-data while the
> more complicated `file-truename' doesn't.

I'd say it's just an unexpected feature of file-chase-links that it saves
match-data.  It shouldn't need to.

> Both throw away match-data immediately.  If match-data is expensive why
> build it in the first place when it's not needed?  Why not make a thing
> like `fast-string-match' available in Lisp?

It's not the match data that's expensive.  It's the save-match-data.
The match-data is built cheaply during the call to string-match in the form
of a C data structure.  It's only when `match-data' is called that it ends
up building a Lisp lisp (sometimes with markers to boot).


reply via email to

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