diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2021-05-08 13:37:31 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2021-05-08 15:08:19 +0200 |
commit | b02dfe41b255ac663c3ac3a4475a4933186de1e7 (patch) | |
tree | 783d3bd5cbf61c8d32fee36281f877e69f4094b8 /include/erebos | |
parent | 0989a657c25476f2ab80448b094ef0dd5c9c0beb (diff) |
FRP: use BhvComp memoized value only if not dirty
Diffstat (limited to 'include/erebos')
-rw-r--r-- | include/erebos/frp.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/include/erebos/frp.h b/include/erebos/frp.h index 466da33..8014536 100644 --- a/include/erebos/frp.h +++ b/include/erebos/frp.h @@ -87,6 +87,8 @@ protected: virtual bool needsUpdate(const BhvCurTime &) const; virtual void doUpdate(const BhvCurTime &); + bool isDirty(const BhvCurTime &) const { return dirty; } + vector<weak_ptr<function<void(const BhvCurTime &)>>> watchers; private: void markDirty(const BhvCurTime &, vector<shared_ptr<BhvImplBase>> &); @@ -222,7 +224,7 @@ public: { x = g.impl->get(ctime, f.impl->get(ctime, monostate())); } C get(const BhvCurTime & ctime, const monostate & m) const override - { return x ? x.value() : g.impl->get(ctime, f.impl->get(ctime, m)); } + { return x && !BhvImplBase::isDirty(ctime) ? x.value() : g.impl->get(ctime, f.impl->get(ctime, m)); } private: BhvFun<monostate, B> f; |