From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: find-file-noselect needs save-match-data Date: Thu, 14 Jun 2007 19:18:25 +0200 Message-ID: <85645qsbdq.fsf@lola.goethe.zz> References: <46665AD7.7040706@gmx.at> <87k5ueq23m.fsf@kfs-lx.testafd.dk> <87myz8c10t.fsf@jurta.org> <18030.3441.204697.244518@rgrjr.dyndns.org> <87zm3515r4.fsf@jurta.org> <85k5u8x2gm.fsf@lola.goethe.zz> <87r6og6czf.fsf@catnip.gol.com> <85bqfkx0i5.fsf@lola.goethe.zz> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1181841537 18124 80.91.229.12 (14 Jun 2007 17:18:57 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 14 Jun 2007 17:18:57 +0000 (UTC) Cc: miles.bader@necel.com, schwab@suse.de, emacs-devel@gnu.org, juri@jurta.org, Stefan Monnier , miles@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jun 14 19:18:53 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HysyC-0003UC-D0 for ged-emacs-devel@m.gmane.org; Thu, 14 Jun 2007 19:18:52 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HysyB-00039t-Jk for ged-emacs-devel@m.gmane.org; Thu, 14 Jun 2007 13:18:51 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hysy7-00037X-Sb for emacs-devel@gnu.org; Thu, 14 Jun 2007 13:18:47 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hysy7-00037A-GD for emacs-devel@gnu.org; Thu, 14 Jun 2007 13:18:47 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hysy7-00036y-3a for emacs-devel@gnu.org; Thu, 14 Jun 2007 13:18:47 -0400 Original-Received: from mail-in-08.arcor-online.net ([151.189.21.48]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Hysy4-0004RD-CB; Thu, 14 Jun 2007 13:18:44 -0400 Original-Received: from mail-in-01-z2.arcor-online.net (mail-in-06-z2.arcor-online.net [151.189.8.18]) by mail-in-08.arcor-online.net (Postfix) with ESMTP id 9512527AC9C; Thu, 14 Jun 2007 19:18:40 +0200 (CEST) Original-Received: from mail-in-01.arcor-online.net (mail-in-01.arcor-online.net [151.189.21.41]) by mail-in-01-z2.arcor-online.net (Postfix) with ESMTP id 856175BD73; Thu, 14 Jun 2007 19:18:40 +0200 (CEST) Original-Received: from lola.goethe.zz (dslb-084-061-030-031.pools.arcor-ip.net [84.61.30.31]) by mail-in-01.arcor-online.net (Postfix) with ESMTP id 3251319B333; Thu, 14 Jun 2007 19:18:40 +0200 (CEST) Original-Received: by lola.goethe.zz (Postfix, from userid 1002) id 858591C3E01D; Thu, 14 Jun 2007 19:18:26 +0200 (CEST) In-Reply-To: (Richard Stallman's message of "Thu\, 14 Jun 2007 12\:19\:43 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) X-Virus-Scanned: ClamAV 0.90.3/3418/Thu Jun 14 15:03:06 2007 on mail-in-01.arcor-online.net X-Virus-Status: Clean X-detected-kernel: Linux 2.4-2.6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:72882 Archived-At: Richard Stallman 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