From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Han-Wen Nienhuys Newsgroups: gmane.lisp.guile.devel Subject: Re: freeing srcprops ? Date: Fri, 19 Jan 2007 12:52:32 +0100 Message-ID: <45B0B100.9080703@xs4all.nl> References: <45AF7E7F.1000600@xs4all.nl> <87fya7ap9f.fsf@zip.com.au> Reply-To: hanwen@xs4all.nl NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1169207602 1947 80.91.229.12 (19 Jan 2007 11:53:22 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 19 Jan 2007 11:53:22 +0000 (UTC) Cc: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Jan 19 12:53:20 2007 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1H7sJ1-0006mB-7w for guile-devel@m.gmane.org; Fri, 19 Jan 2007 12:53:15 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H7sJ0-0003nh-PB for guile-devel@m.gmane.org; Fri, 19 Jan 2007 06:53:14 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1H7sIW-0003Qx-4K for guile-devel@gnu.org; Fri, 19 Jan 2007 06:52:44 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1H7sIT-0003PG-FF for guile-devel@gnu.org; Fri, 19 Jan 2007 06:52:43 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H7sIT-0003P3-7g for guile-devel@gnu.org; Fri, 19 Jan 2007 06:52:41 -0500 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1H7sIS-0005E5-Dg for guile-devel@gnu.org; Fri, 19 Jan 2007 06:52:40 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1H7sIK-0004Wv-D9 for guile-devel@gnu.org; Fri, 19 Jan 2007 12:52:32 +0100 Original-Received: from muurbloem.xs4all.nl ([213.84.26.127]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 19 Jan 2007 12:52:32 +0100 Original-Received: from hanwen by muurbloem.xs4all.nl with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 19 Jan 2007 12:52:32 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-To: guile-devel@gnu.org Original-Lines: 96 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: muurbloem.xs4all.nl User-Agent: Thunderbird 1.5.0.9 (X11/20061219) In-Reply-To: <87fya7ap9f.fsf@zip.com.au> X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:6451 Archived-At: Kevin Ryde escreveu: > Han-Wen Nienhuys writes: >> SCM >> scm_make_srcprops (long line, int col, SCM filename, SCM copy, SCM plist) >> { >> + if (!SCM_UNBNDP (filename)) >> + plist = scm_acons (scm_sym_filename, filename, plist); > > Can those two cells be shared among all source props for the same > file, to save space? see below. Hmmm, on 2nd thought, there is a race condition in this code. Lemme see. >> + SCM_RETURN_NEWSMOB3 (scm_tc16_srcprops, >> + SRCPROPMAKPOS (line, col), > > If col is a freaky big value then perhaps put it in the plist. Could col is 0x0FFF max, which 4096. Seems plenty for me. We could of course increase this limit, but then the max number of lines goes down from its current value of 1M. commit 1e8cecc70617d69bd93e8c4761aedf1008f454f6 Author: Han-Wen Nienhuys Date: Fri Jan 19 12:46:57 2007 +0100 Reuse last filename acons if possible. This saves on memory use, since plist usually is SCM_EOL. diff --git a/libguile/srcprop.c b/libguile/srcprop.c index b44b503..8d61272 100644 --- a/libguile/srcprop.c +++ b/libguile/srcprop.c @@ -88,7 +88,6 @@ SCM_GLOBAL_SYMBOL (scm_sym_breakpoint, "breakpoint"); scm_t_bits scm_tc16_srcprops; - static SCM srcprops_mark (SCM obj) { @@ -117,12 +116,33 @@ scm_c_source_property_breakpoint_p (SCM form) } +/* + A protected cells whose cdr contains the last plist + used if plist contains only the filename. + + This works because scm_set_source_property_x does + not use assoc-set! for modifying the plist. + */ +static SCM scm_last_plist_filename; SCM scm_make_srcprops (long line, int col, SCM filename, SCM copy, SCM plist) { if (!SCM_UNBNDP (filename)) - plist = scm_acons (scm_sym_filename, filename, plist); + { + SCM old_plist = plist; + if (old_plist == SCM_EOL + && SCM_CDADR (scm_last_plist_filename) == filename) + { + plist = SCM_CDR (scm_last_plist_filename); + } + else + { + plist = scm_acons (scm_sym_filename, filename, plist); + if (old_plist == SCM_EOL) + SCM_SETCDR (scm_last_plist_filename, plist); + } + } SCM_RETURN_NEWSMOB3 (scm_tc16_srcprops, SRCPROPMAKPOS (line, col), @@ -300,6 +320,10 @@ scm_init_srcprop () scm_source_whash = scm_make_weak_key_hash_table (scm_from_int (2047)); scm_c_define ("source-whash", scm_source_whash); + scm_last_plist_filename + = scm_permanent_object (scm_cons (SCM_EOL, + scm_acons (SCM_EOL, SCM_EOL, SCM_EOL))); + #include "libguile/srcprop.x" } -- Han-Wen Nienhuys - hanwen@xs4all.nl - http://www.xs4all.nl/~hanwen _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel