mes: Fix assq to improve performance.

* src/mes.c (assq): Special case eq_p to improve performance.
This commit is contained in:
Jan Nieuwenhuizen 2017-12-12 20:25:48 +01:00
parent 0f042b6ea6
commit 90249f595f

View file

@ -641,9 +641,24 @@ call (SCM fn, SCM x)
SCM
assq (SCM x, SCM a)
{
//FIXME: move into fast-non eq_p-ing assq core:assq?
//while (a != cell_nil && x != CAAR (a)) a = CDR (a);
while (a != cell_nil && eq_p (x, CAAR (a)) == cell_f) a = CDR (a);
switch (TYPE (x))
{
case TCHAR:
case TNUMBER:
{
SCM v = VALUE (x);
while (a != cell_nil && v != VALUE (CAAR (a))) a = CDR (a); break;
}
case TKEYWORD:
{
SCM v = STRING (x);
while (a != cell_nil && v != STRING (CAAR (a))) a = CDR (a); break;
}
// case TSYMBOL:
// case TSPECIAL:
default:
while (a != cell_nil && x != CAAR (a)) a = CDR (a); break;
}
return a != cell_nil ? CAR (a) : cell_f;
}