From: Rob Browning <rlb@defaultvalue.org>
To: guile-devel@gnu.org
Subject: [PATCH 1/1] scm_set_source_properties_x: optimize if only name, line, and/or col
Date: Sun, 17 Jan 2021 16:24:58 -0600 [thread overview]
Message-ID: <20210117222458.902736-1-rlb@defaultvalue.org> (raw)
* libguile/srcprop.c (scm_set_source_properties_x): When only a subset
of file, line, and column fields are specified, store the data as a
srcprops object (tc16_srcprops) rather than an alist.
---
Proposed for at least 3.x. If we want some additional tests, then
one option might be a public or private predicate to test for a
srcprops object (at least for scheme level testing).
libguile/srcprop.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/libguile/srcprop.c b/libguile/srcprop.c
index 0ebbfc301..fea68e031 100644
--- a/libguile/srcprop.c
+++ b/libguile/srcprop.c
@@ -168,8 +168,6 @@ SCM_DEFINE (scm_source_properties, "source-properties", 1, 0, 0,
#define SCM_VALIDATE_NIM(pos, scm) \
SCM_MAKE_VALIDATE_MSG (pos, scm, NIMP, "non-immediate")
-/* Perhaps this procedure should look through an alist
- and try to make a srcprops-object...? */
SCM_DEFINE (scm_set_source_properties_x, "set-source-properties!", 2, 0, 0,
(SCM obj, SCM alist),
"Install the association list @var{alist} as the source property\n"
@@ -177,9 +175,17 @@ SCM_DEFINE (scm_set_source_properties_x, "set-source-properties!", 2, 0, 0,
#define FUNC_NAME s_scm_set_source_properties_x
{
SCM_VALIDATE_NIM (1, obj);
-
- scm_weak_table_putq_x (scm_source_whash, obj, alist);
-
+ SCM fname = scm_assq_ref (alist, scm_sym_filename);
+ SCM col = scm_assq_ref (alist, scm_sym_column);
+ SCM line = scm_assq_ref (alist, scm_sym_line);
+ const int n = ((fname == SCM_BOOL_F) ? 0 : 1)
+ + ((col == SCM_BOOL_F) ? 0 : 1)
+ + ((line == SCM_BOOL_F) ? 0 : 1);
+
+ if (scm_ilength (alist) == n)
+ scm_i_set_source_properties_x (obj, line, col, fname);
+ else
+ scm_weak_table_putq_x (scm_source_whash, obj, alist);
return alist;
}
#undef FUNC_NAME
--
2.29.2
next reply other threads:[~2021-01-17 22:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-17 22:24 Rob Browning [this message]
2021-01-17 22:55 ` [PATCH 1/1] scm_set_source_properties_x: optimize if only name, line, and/or col Bruce Korb
2021-03-09 20:52 ` Andy Wingo
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=20210117222458.902736-1-rlb@defaultvalue.org \
--to=rlb@defaultvalue.org \
--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).