From: Jan Nieuwenhuizen Date: Tue, 12 Dec 2017 19:25:48 +0000 (+0100) Subject: mes: Fix assq to improve performance. X-Git-Url: https://jxself.org/git/?p=mes.git;a=commitdiff_plain;h=90249f595f3f7c122628dd885b67d96956b2f270 mes: Fix assq to improve performance. * src/mes.c (assq): Special case eq_p to improve performance. --- diff --git a/src/mes.c b/src/mes.c index 92f47124..f89490e7 100644 --- a/src/mes.c +++ b/src/mes.c @@ -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; }