[apps/graph] Limited number of cached functions

The caches used for function values memoization are now stored in
ContinuousFunctionStore : there are now only a fixed number, instead of
one per function. This effectively enables caching only for the first
few functions on screen, while reducing the memory usage.

Change-Id: I2ade091717f73a14a756fe527c773db8e8627be7
This commit is contained in:
Gabriel Ozouf
2020-06-09 16:19:23 +02:00
committed by Émilie Feral
parent 95fef86ec0
commit 42fcf557b8
8 changed files with 43 additions and 24 deletions

View File

@@ -80,7 +80,10 @@ public:
Poincare::Expression sumBetweenBounds(double start, double end, Poincare::Context * context) const override;
// Cache
ContinuousFunctionCache * cache() const { return const_cast<ContinuousFunctionCache *>(&m_cache); }
ContinuousFunctionCache * cache() const { return m_cache; }
void setCache(ContinuousFunctionCache * v) { m_cache = v; }
void clearCache() { m_cache = nullptr; }
bool cacheIsFilled() const { return cache() && cache()->filled(); }
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
@@ -125,7 +128,7 @@ private:
RecordDataBuffer * recordData() const;
template<typename T> Poincare::Coordinate2D<T> templatedApproximateAtParameter(T t, Poincare::Context * context) const;
Model m_model;
ContinuousFunctionCache m_cache;
ContinuousFunctionCache * m_cache;
};
}