core: memq: Prepare for M2-Planet.

* src/lib.c (memq): Prepare for M2-Planet.
This commit is contained in:
Jan Nieuwenhuizen 2019-10-24 21:23:38 +02:00
parent 6f2e0a405e
commit 92ceecc081
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
1 changed files with 21 additions and 9 deletions

View File

@ -128,19 +128,31 @@ memq (SCM x, SCM a)
if (t == TCHAR || t == TNUMBER) if (t == TCHAR || t == TNUMBER)
{ {
long v = VALUE (x); long v = VALUE (x);
while (a != cell_nil && v != VALUE (CAR (a))) while (a != cell_nil)
a = CDR (a); {
if (v == VALUE (CAR (a)))
return a;
a = CDR (a);
}
return cell_f;
} }
else if (t == TKEYWORD) if (t == TKEYWORD)
{ {
while (a != cell_nil && (TYPE (CAR (a)) != TKEYWORD || string_equal_p (x, CAR (a)) == cell_f)) while (a != cell_nil)
a = CDR (a); {
if (TYPE (CAR (a)) == TKEYWORD)
if (string_equal_p (x, CAR (a)) == cell_t)
return a;
a = CDR (a);
}
return cell_f;
} }
else while (a != cell_nil)
while (a != cell_nil && x != CAR (a)) {
if (x == CAR (a))
return a;
a = CDR (a); a = CDR (a);
if (a != cell_nil) }
return a;
return cell_f; return cell_f;
} }