all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: rms@gnu.org, miles.bader@necel.com, schwab@suse.de,
	emacs-devel@gnu.org, juri@jurta.org, miles@gnu.org
Subject: Re: find-file-noselect needs save-match-data
Date: Thu, 14 Jun 2007 08:57:07 +0200	[thread overview]
Message-ID: <4670E6C3.7070505@gmx.at> (raw)
In-Reply-To: <jwv645r3gyc.fsf-monnier+emacs@gnu.org>

 > Then what's the advantage compared to using save-match-data?  This whole
 > discussion started because people want to add save-match-data everywhere and
 > I pointed out that it's very rarely necessary, and it can be costly (where
 > the "it" is generating the Lisp-level match data).

Yes, I proposed to add `save-match-data' to a variety of file handling
functions at the outermost level.  The main reason for my proposal was
to introduce some sort of consistency among functions in files.el with
respect to saving match-data.  If you proposed to remove _all_ instances
of `save-match-data's from files.el instead, you get my 100% agreement.
ISTR also that I was the first in this thread to mention that saving
`match-data' is expensive.  If we really cared about this we could start
right in files.el.  The following instance in `abbreviate-file-name'

			 (save-match-data
			   (string-match "^[a-zA-`]:/$" filename)))))

should be replaced by binding the outcome of (match-string 1) of the
previous string-match around it.  Though using

			 (fast-string-match "^[a-zA-`]:/$" filename))))

instead would be clearer and make such binding unnecessary ;-)

 > The suggestion to have a specialized string-match operation that preserves
 > match-data was for performance reasons, AFAICT, like fast_c_string_match.

It was my suggestion to introduce - on the Lisp level - somthing like
fast_string_match.  My motivation was completely different though: Code
using that function should reassure the reader that there would be no
need to save match-data around it.  It goes without saying that a "fast"
string matching function should return the same value as `string-match'
and _not_ `match-data'.

I still believe that people spend more valuable time _thinking_ about
whether match-data should be saved in a specific circumstance than when
it is actually saved on their computer.  Look at info.el: In
`Info-dir-remove-duplicates' we have

	    (while (re-search-forward "^\\(\\w.*\\)\n\\*" limit t)
	      (when (if re (save-match-data (string-match re (match-string 1)))
		      (equal name (match-string 1)))
		
and in `Info-fontify-node'

			(cond ((save-match-data (looking-back "\\<see"))
			       "")
			      ((save-match-data (looking-back "\\<in"))
			       "")
			      ((memq (char-before) '(nil ?\. ?! ??))
                                "See ")
			      ((save-match-data
				 (save-excursion
				   (search-forward "\n\n" start t)))
			       "See ")
			      (t "see "))))

both deeply nested in loops.  Did I mention that Info's fontification
can be a pain?

  parent reply	other threads:[~2007-06-14  6:57 UTC|newest]

Thread overview: 117+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-04 15:17 find-file-noselect needs save-match-data Herbert Euler
2007-06-04 16:05 ` martin rudalics
2007-06-05  3:10   ` Herbert Euler
2007-06-05  5:52     ` martin rudalics
2007-06-05 22:32       ` Richard Stallman
2007-06-06  1:13   ` Stefan Monnier
2007-06-06  1:44     ` Herbert Euler
2007-06-06  6:58       ` martin rudalics
2007-06-06  7:25         ` David Kastrup
2007-06-06 22:09         ` Richard Stallman
2007-06-06 12:14       ` Stefan Monnier
2007-06-06 22:09         ` Richard Stallman
2007-06-06  6:57     ` martin rudalics
2007-06-06 12:17       ` Stefan Monnier
2007-06-06 12:33         ` Lennart Borgman (gmail)
2007-06-06 12:49         ` martin rudalics
2007-06-06 22:10         ` Richard Stallman
2007-06-06 22:29           ` Stefan Monnier
2007-06-08  7:11             ` Richard Stallman
2007-06-08  8:31               ` Kim F. Storm
2007-06-08  9:42                 ` martin rudalics
2007-06-08 10:31                   ` Kim F. Storm
2007-06-09  9:45                     ` Richard Stallman
2007-06-10  0:05                   ` Herbert Euler
2007-06-10  0:11                     ` Herbert Euler
2007-06-09  9:46                 ` Richard Stallman
2007-06-09 21:32                   ` Juri Linkov
2007-06-09 21:59                     ` David House
2007-06-09 22:43                       ` Juri Linkov
2007-06-09 22:53                       ` Jason Rumney
2007-06-09 23:59                       ` Miles Bader
2007-06-10  0:02                         ` Drew Adams
2007-06-10 13:19                     ` Richard Stallman
2007-06-12  3:05                       ` Bob Rogers
2007-06-12  4:06                         ` Miles Bader
2007-06-12 16:45                           ` Juri Linkov
2007-06-12 17:46                             ` Andreas Schwab
2007-06-12 21:55                               ` David Kastrup
2007-06-12 22:10                                 ` Miles Bader
2007-06-12 22:37                                   ` David Kastrup
2007-06-13 16:22                                     ` Richard Stallman
2007-06-13 17:31                                       ` Stefan Monnier
2007-06-13 18:33                                         ` David Kastrup
2007-06-13 19:55                                           ` Stefan Monnier
2007-06-14  6:37                                             ` Herbert Euler
2007-06-15  8:48                                               ` Richard Stallman
2007-06-15 14:22                                                 ` Stefan Monnier
2007-06-15 16:03                                                 ` Herbert Euler
2007-06-14  6:57                                             ` martin rudalics
2007-06-14 14:36                                               ` Stefan Monnier
2007-06-14 16:05                                                 ` Herbert Euler
2007-06-14 16:22                                                   ` Stefan Monnier
2007-06-15  1:59                                                     ` Herbert Euler
2007-06-15  8:49                                                     ` Richard Stallman
2007-06-15  8:49                                                   ` Richard Stallman
2007-06-14  6:57                                         ` martin rudalics [this message]
2007-06-15  8:48                                           ` Richard Stallman
2007-06-15 14:23                                             ` Stefan Monnier
2007-06-15 22:45                                               ` Richard Stallman
2007-06-17 19:54                                           ` Juri Linkov
2007-06-17 20:27                                             ` Lennart Borgman (gmail)
2007-06-14 16:19                                         ` Richard Stallman
2007-06-14 17:18                                           ` David Kastrup
2007-06-15 19:21                                             ` Richard Stallman
2007-06-15 19:52                                               ` Stefan Monnier
2007-06-13 23:39                                       ` Miles Bader
2007-06-14  0:52                                         ` Stefan Monnier
2007-06-14  6:58                                           ` martin rudalics
2007-06-14 16:20                                         ` Richard Stallman
2007-06-14 18:50                                           ` Stefan Monnier
2007-06-15  6:31                                             ` martin rudalics
2007-06-15 14:20                                               ` Stefan Monnier
2007-06-15 15:55                                                 ` Herbert Euler
2007-06-15 19:22                                               ` Richard Stallman
2007-06-16 10:01                                                 ` martin rudalics
2007-06-16 22:35                                                   ` Richard Stallman
2007-06-15 19:21                                             ` Richard Stallman
2007-06-15 19:55                                               ` Stefan Monnier
2007-06-15 20:03                                                 ` David Kastrup
2007-06-16 18:51                                                   ` Richard Stallman
2007-06-16 19:10                                                     ` David Kastrup
2007-06-17 21:49                                                       ` Richard Stallman
2007-06-18  5:16                                                         ` David Kastrup
2007-06-18 21:30                                                           ` Richard Stallman
2007-06-18 21:42                                                             ` David Kastrup
2007-06-19 22:26                                                               ` Richard Stallman
2007-06-19 22:42                                                                 ` David Kastrup
2007-06-25 13:19                                                                   ` Richard Stallman
2007-06-16  3:50                                                 ` Herbert Euler
2007-06-17 12:28                                                   ` Stefan Monnier
2007-06-16 18:51                                                 ` Richard Stallman
2007-06-16 21:39                                                   ` Miles Bader
2007-06-17  8:55                                                     ` Richard Stallman
2007-06-17  3:19                                                   ` Herbert Euler
2007-06-17  3:26                                                     ` Herbert Euler
2007-06-17 21:49                                                     ` Richard Stallman
2007-06-17 12:50                                                   ` Stefan Monnier
2007-06-18  7:25                                                     ` Richard Stallman
2007-06-20  8:07                                                       ` Herbert Euler
2007-06-20 14:12                                                         ` Juri Linkov
2007-06-20 14:44                                                           ` Herbert Euler
2007-06-21  1:07                                                           ` Richard Stallman
2007-06-21  1:29                                                             ` Herbert Euler
2007-06-21  6:31                                                               ` David Kastrup
2007-06-28 14:06                                                                 ` Herbert Euler
2007-06-29 15:07                                                                   ` Herbert Euler
2007-07-06 17:05                                                                 ` byte-compiling an elisp-file fails in Emacs 22.1 (reproducable) klaus.berndl
2007-07-06 22:20                                                                   ` Jason Rumney
2007-07-07 13:06                                                                   ` Richard Stallman
2007-07-08  6:30                                                                     ` AW: " klaus.berndl
2007-06-22  1:51                                                               ` find-file-noselect needs save-match-data Richard Stallman
2007-06-20 17:36                                                         ` Richard Stallman
2007-06-13 16:21                                 ` Richard Stallman
2007-06-05  5:18 ` Richard Stallman
2007-06-06  1:10 ` Stefan Monnier
2007-06-14 16:19 ` Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2007-06-06  0:25 Herbert Euler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4670E6C3.7070505@gmx.at \
    --to=rudalics@gmx.at \
    --cc=emacs-devel@gnu.org \
    --cc=juri@jurta.org \
    --cc=miles.bader@necel.com \
    --cc=miles@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=rms@gnu.org \
    --cc=schwab@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.