From 1e62bbf8c9d64f87966be7ac1a81bb30dd6ab21e Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Thu, 20 Oct 2016 00:21:06 +0200 Subject: [PATCH] Avoid adding top of environment to cache. * mes.c (assq_ref_cache): Only consider caching symbols deeper than 4*CACHE_SIZE depth. 50% speedup. --- mes.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mes.c b/mes.c index 95787bcd..2d32c6c3 100644 --- a/mes.c +++ b/mes.c @@ -370,9 +370,10 @@ assq_ref_cache (scm *x, scm *a) x->value++; scm *c = cache_lookup (x); if (c != &scm_undefined) return c; - while (a != &scm_nil && x != a->car->car) a = a->cdr; + int i = 0; + while (a != &scm_nil && x != a->car->car) {i++;a = a->cdr;} if (a == &scm_nil) return &scm_undefined; - cache_save (a->car); + if (i>4*CACHE_SIZE) cache_save (a->car); return a->car->cdr; } #endif // ENV_CACHE