unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Han-Wen Nienhuys <hanwen@xs4all.nl>
Cc: guile-devel@gnu.org
Subject: Re: freeing srcprops ?
Date: Fri, 19 Jan 2007 12:52:32 +0100	[thread overview]
Message-ID: <45B0B100.9080703@xs4all.nl> (raw)
In-Reply-To: <87fya7ap9f.fsf@zip.com.au>

Kevin Ryde escreveu:
> Han-Wen Nienhuys <hanwen@xs4all.nl> 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 <hanwen@lilypond.org>
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


  parent reply	other threads:[~2007-01-19 11:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-17  0:22 freeing srcprops ? Han-Wen Nienhuys
2007-01-18 14:04 ` Han-Wen Nienhuys
2007-01-18 23:28   ` Kevin Ryde
2007-01-19 10:37     ` Han-Wen Nienhuys
2007-01-19 11:52     ` Han-Wen Nienhuys [this message]
2007-01-26 22:15       ` Kevin Ryde
2007-01-26 23:33         ` Han-Wen Nienhuys
2007-01-18 23:20 ` Kevin Ryde
2007-01-28  9:08   ` Neil Jerram
2007-01-29 11:39     ` Han-Wen Nienhuys
2007-01-29 21:35       ` Neil Jerram
2007-01-29 23:31         ` Han-Wen Nienhuys
2007-01-30 12:40           ` Ludovic Courtès
2007-01-30 19:14             ` Han-Wen Nienhuys
2007-01-30 12:21       ` Mikael Djurfeldt
2007-01-30 12:52         ` Han-Wen Nienhuys

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

  List information: https://www.gnu.org/software/guile/

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

  git send-email \
    --in-reply-to=45B0B100.9080703@xs4all.nl \
    --to=hanwen@xs4all.nl \
    --cc=guile-devel@gnu.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).