[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 07/07: Let assv/assoc shortcircuit to assq where feasibl
From: |
Andy Wingo |
Subject: |
[Guile-commits] 07/07: Let assv/assoc shortcircuit to assq where feasible |
Date: |
Sun, 7 Aug 2016 21:24:31 +0000 (UTC) |
wingo pushed a commit to branch stable-2.0
in repository guile.
commit a3ad59be1bbe65963ec1e7f3699add6d7bdd6523
Author: David Kastrup <address@hidden>
Date: Thu Feb 11 12:31:48 2016 +0100
Let assv/assoc shortcircuit to assq where feasible
* libguile/alist.c (scm_sloppy_assv, scm_sloppy_assoc):
(scm_assv, scm_assoc): Shortcircuit to scm_assq where feasible.
---
libguile/alist.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/libguile/alist.c b/libguile/alist.c
index f33aa41..5986410 100644
--- a/libguile/alist.c
+++ b/libguile/alist.c
@@ -28,6 +28,7 @@
#include "libguile/validate.h"
#include "libguile/pairs.h"
+#include "libguile/numbers.h"
#include "libguile/alist.h"
@@ -72,6 +73,11 @@ SCM_DEFINE (scm_sloppy_assv, "sloppy-assv", 2, 0, 0,
"Recommended only for use in Guile internals.")
#define FUNC_NAME s_scm_sloppy_assv
{
+ /* In Guile, `assv' is the same as `assq' for keys of all types except
+ numbers. */
+ if (!SCM_NUMP (key))
+ return scm_sloppy_assq (key, alist);
+
for (; scm_is_pair (alist); alist = SCM_CDR (alist))
{
SCM tmp = SCM_CAR (alist);
@@ -90,6 +96,10 @@ SCM_DEFINE (scm_sloppy_assoc, "sloppy-assoc", 2, 0, 0,
"Recommended only for use in Guile internals.")
#define FUNC_NAME s_scm_sloppy_assoc
{
+ /* Immediate values can be checked using `eq?'. */
+ if (SCM_IMP (key))
+ return scm_sloppy_assq (key, alist);
+
for (; scm_is_pair (alist); alist = SCM_CDR (alist))
{
SCM tmp = SCM_CAR (alist);
@@ -139,6 +149,12 @@ SCM_DEFINE (scm_assv, "assv", 2, 0, 0,
#define FUNC_NAME s_scm_assv
{
SCM ls = alist;
+
+ /* In Guile, `assv' is the same as `assq' for keys of all types except
+ numbers. */
+ if (!SCM_NUMP (key))
+ return scm_assq (key, alist);
+
for(; scm_is_pair (ls); ls = SCM_CDR (ls))
{
SCM tmp = SCM_CAR (ls);
@@ -160,6 +176,11 @@ SCM_DEFINE (scm_assoc, "assoc", 2, 0, 0,
#define FUNC_NAME s_scm_assoc
{
SCM ls = alist;
+
+ /* Immediate values can be checked using `eq?'. */
+ if (SCM_IMP (key))
+ return scm_assq (key, alist);
+
for(; scm_is_pair (ls); ls = SCM_CDR (ls))
{
SCM tmp = SCM_CAR (ls);
- [Guile-commits] branch stable-2.0 updated (edd6d6e -> a3ad59b), Andy Wingo, 2016/08/07
- [Guile-commits] 04/07: Capture full path to GUILE_FOR_BUILD., Andy Wingo, 2016/08/07
- [Guile-commits] 02/07: Fix typo about pattern variables, Andy Wingo, 2016/08/07
- [Guile-commits] 05/07: Recognize nios2 as compilation target, Andy Wingo, 2016/08/07
- [Guile-commits] 03/07: Fix grammar in api-compound.texi, Andy Wingo, 2016/08/07
- [Guile-commits] 07/07: Let assv/assoc shortcircuit to assq where feasible,
Andy Wingo <=
- [Guile-commits] 06/07: Fix iconv encoding of long strings, Andy Wingo, 2016/08/07
- [Guile-commits] 01/07: Manual recommends against SRFI-10, Andy Wingo, 2016/08/07