Avoid adding top of environment to cache.

* mes.c (assq_ref_cache): Only consider caching symbols deeper than
  4*CACHE_SIZE depth.  50% speedup.
This commit is contained in:
Jan Nieuwenhuizen 2016-10-20 00:21:06 +02:00
parent 7885096526
commit 1e62bbf8c9
1 changed files with 3 additions and 2 deletions

5
mes.c
View File

@ -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