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:
parent
7885096526
commit
1e62bbf8c9
5
mes.c
5
mes.c
|
@ -370,9 +370,10 @@ assq_ref_cache (scm *x, scm *a)
|
||||||
x->value++;
|
x->value++;
|
||||||
scm *c = cache_lookup (x);
|
scm *c = cache_lookup (x);
|
||||||
if (c != &scm_undefined) return c;
|
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;
|
if (a == &scm_nil) return &scm_undefined;
|
||||||
cache_save (a->car);
|
if (i>4*CACHE_SIZE) cache_save (a->car);
|
||||||
return a->car->cdr;
|
return a->car->cdr;
|
||||||
}
|
}
|
||||||
#endif // ENV_CACHE
|
#endif // ENV_CACHE
|
||||||
|
|
Loading…
Reference in a new issue