[apps/graph] Changed cache tolerance

This fixes a bug where, when drawing 1/x, a vertical bar would appear on
0, because of false positive cache hits.

Change-Id: I2eafeac5e254c8a556769a41c8edc532db44383a
This commit is contained in:
Gabriel Ozouf
2020-06-23 17:07:55 +02:00
committed by Émilie Feral
parent beb228fa78
commit b0533e6836
2 changed files with 17 additions and 1 deletions

View File

@@ -19,6 +19,14 @@ void ContinuousFunctionCache::PrepareForCaching(void * fun, ContinuousFunctionCa
}
ContinuousFunction * function = static_cast<ContinuousFunction *>(fun);
if (tStep < 3 * k_cacheHitTolerance) {
/* If tStep is lower than twice the tolerance, we risk shifting the index
* by 1 for cache hits. As an added safety, we add another buffer of
* k_cacheHitTolerance, raising the threshold for caching to three times
* the tolerance. */
function->clearCache();
return;
}
if (function->cache() != cache) {
cache->clear();
function->setCache(cache);