1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-23 12:00:21 +02:00

* alist.c: minimize scope of the tmp variables, and initialize

them when declared. The strange SCM_NIMP tests are replaced by
SCM_CONSP tests that more closely reflect the intended semantics.
However, we don't get a performance penalty here, because the
SCM_CONSP test was performed by the ALISTCELL test anyway.  * The
extremely ugly use of ASRTGO macros was removed: The calls to
ASRTGO were not encapsulated by "#ifndef SCM_RECKLESS", but got a
label parameter that only exists when SCM_RECKLESS is not defined.
This works, because ASRTGO itself is defined in a way that it only
makes use of the label parameter if SCM_RECKLESS is not defined
(shudder!).  Does guile make at all use of the possibility to
define SCM_RECKLESS?  * Codesize is likely to be reduced, since
instead of two calls to SCM_ASSERT performed by the ALISTCELL test
we now only get one test.

* list.c: Use SCM_NNULLP, not SCM_NIMP as appropriate.  Also use
SCM_NULLP instead of SCM_IMP.  Drop use of "register" keyword on
some variables in `list?'.  Fix `reverse' and `reverse!'
primitives to handle improper lists better.
This commit is contained in:
Greg J. Badros 2000-01-06 18:00:33 +00:00
parent 15b3328066
commit e1385ffcd6
2 changed files with 79 additions and 81 deletions

View file

@ -147,12 +147,14 @@ predicate is in use), then @code{#f} is returned. These functions
return the entire alist entry found (i.e. both the key and the value).")
#define FUNC_NAME s_scm_assq
{
SCM tmp;
for(;SCM_NIMP(alist);alist = SCM_CDR(alist)) {
SCM_VALIDATE_ALISTCELL_COPYSCM (2,alist,tmp);
if (SCM_CAR(tmp)==key) return tmp;
}
SCM_VALIDATE_NULL (2,alist);
for (; SCM_CONSP(alist); alist = SCM_CDR(alist))
{
SCM tmp = SCM_CAR(alist);
SCM_VALIDATE_CONS(2, tmp);
if (SCM_CAR(tmp) == key)
return tmp;
}
SCM_VALIDATE_NULL(2, alist);
return SCM_BOOL_F;
}
#undef FUNC_NAME
@ -163,17 +165,14 @@ SCM_DEFINE (scm_assv, "assv", 2, 0, 0,
"Behaves like @code{assq} but uses @code{eqv?} for key comparison.")
#define FUNC_NAME s_scm_assv
{
SCM tmp;
for(;SCM_NIMP(alist);alist = SCM_CDR(alist)) {
SCM_ASRTGO(SCM_CONSP(alist), badlst);
tmp = SCM_CAR(alist);
SCM_ASRTGO(SCM_CONSP(tmp), badlst);
if SCM_NFALSEP(scm_eqv_p(SCM_CAR(tmp), key)) return tmp;
}
# ifndef SCM_RECKLESS
if (!(SCM_NULLP(alist)))
badlst: SCM_WTA(2,alist);
# endif
for(; SCM_CONSP(alist); alist = SCM_CDR(alist))
{
SCM tmp = SCM_CAR(alist);
SCM_VALIDATE_CONS(2, tmp);
if SCM_NFALSEP(scm_eqv_p(SCM_CAR(tmp), key))
return tmp;
}
SCM_VALIDATE_NULL(2, alist);
return SCM_BOOL_F;
}
#undef FUNC_NAME
@ -184,12 +183,14 @@ SCM_DEFINE (scm_assoc, "assoc", 2, 0, 0,
"Behaves like @code{assq} but uses @code{equal?} for key comparison.")
#define FUNC_NAME s_scm_assoc
{
SCM tmp;
for(;SCM_NIMP(alist);alist = SCM_CDR(alist)) {
SCM_VALIDATE_ALISTCELL_COPYSCM (2,alist,tmp);
if SCM_NFALSEP(scm_equal_p(SCM_CAR(tmp), key)) return tmp;
}
SCM_VALIDATE_NULL (2,alist);
for(; SCM_CONSP(alist); alist = SCM_CDR(alist))
{
SCM tmp = SCM_CAR(alist);
SCM_VALIDATE_CONS(2, tmp);
if SCM_NFALSEP(scm_equal_p(SCM_CAR(tmp), key))
return tmp;
}
SCM_VALIDATE_NULL(2, alist);
return SCM_BOOL_F;
}
#undef FUNC_NAME