From 2bfdc482a65ad8789ce259ca21450149cd3bf60a Mon Sep 17 00:00:00 2001 From: Gabriel Ozouf Date: Fri, 3 Jul 2020 16:51:03 +0200 Subject: [PATCH] [apps/continuous_function] Cut clearCache method Inlined call to ContinuousFunction::clearCache and removed the method, as its name was confusing. Change-Id: I54454fb0b06167e01249afaa5b23932451125f2e --- apps/shared/continuous_function.cpp | 8 ++++---- apps/shared/continuous_function.h | 1 - apps/shared/continuous_function_cache.cpp | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/apps/shared/continuous_function.cpp b/apps/shared/continuous_function.cpp index 885f5f2e7..b2688fdc3 100644 --- a/apps/shared/continuous_function.cpp +++ b/apps/shared/continuous_function.cpp @@ -125,7 +125,7 @@ void ContinuousFunction::setPlotType(PlotType newPlotType, Poincare::Preferences recordData()->setPlotType(newPlotType); - clearCache(); + setCache(nullptr); // Recompute the layouts m_model.tidy(); @@ -253,12 +253,12 @@ float ContinuousFunction::tMax() const { void ContinuousFunction::setTMin(float tMin) { recordData()->setTMin(tMin); - clearCache(); + setCache(nullptr); } void ContinuousFunction::setTMax(float tMax) { recordData()->setTMax(tMax); - clearCache(); + setCache(nullptr); } void * ContinuousFunction::Model::expressionAddress(const Ion::Storage::Record * record) const { @@ -352,7 +352,7 @@ Poincare::Expression ContinuousFunction::sumBetweenBounds(double start, double e } Ion::Storage::Record::ErrorStatus ContinuousFunction::setContent(const char * c, Poincare::Context * context) { - clearCache(); + setCache(nullptr); return ExpressionModelHandle::setContent(c, context); } diff --git a/apps/shared/continuous_function.h b/apps/shared/continuous_function.h index 0874941a4..b6ea846bb 100644 --- a/apps/shared/continuous_function.h +++ b/apps/shared/continuous_function.h @@ -82,7 +82,6 @@ public: // Cache ContinuousFunctionCache * cache() const { return m_cache; } void setCache(ContinuousFunctionCache * v) { m_cache = v; } - void clearCache() { m_cache = nullptr; } Ion::Storage::Record::ErrorStatus setContent(const char * c, Poincare::Context * context) override; private: constexpr static float k_polarParamRangeSearchNumberOfPoints = 100.0f; // This is ad hoc, no special justification diff --git a/apps/shared/continuous_function_cache.cpp b/apps/shared/continuous_function_cache.cpp index 8e165b14b..24435e926 100644 --- a/apps/shared/continuous_function_cache.cpp +++ b/apps/shared/continuous_function_cache.cpp @@ -24,7 +24,7 @@ void ContinuousFunctionCache::PrepareForCaching(void * fun, ContinuousFunctionCa * 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(); + function->setCache(nullptr); return; } if (function->cache() != cache) {