diff --git a/src/pathfinder/yapf/yapf_base.hpp b/src/pathfinder/yapf/yapf_base.hpp index de46ebb6c9..0c49d16ca5 100644 --- a/src/pathfinder/yapf/yapf_base.hpp +++ b/src/pathfinder/yapf/yapf_base.hpp @@ -227,10 +227,6 @@ public: bool bValid = Yapf().PfCalcCost(n, &tf); - if (bCached) { - Yapf().PfNodeCacheFlush(n); - } - if (bValid) bValid = Yapf().PfCalcEstimate(n); /* have the cost or estimate callbacks marked this node as invalid? */ diff --git a/src/pathfinder/yapf/yapf_costcache.hpp b/src/pathfinder/yapf/yapf_costcache.hpp index 0c0aa729fd..5b7c0c0c65 100644 --- a/src/pathfinder/yapf/yapf_costcache.hpp +++ b/src/pathfinder/yapf/yapf_costcache.hpp @@ -14,7 +14,7 @@ /** * CYapfSegmentCostCacheNoneT - the formal only yapf cost cache provider that implements - * PfNodeCacheFetch() and PfNodeCacheFlush() callbacks. Used when nodes don't have CachedData + * PfNodeCacheFetch(). Used when nodes don't have CachedData * defined (they don't count with any segment cost caching). */ template @@ -32,64 +32,8 @@ public: { return false; } - - /** - * Called by YAPF to flush the cached segment cost data back into cache storage. - * Current cache implementation doesn't use that. - */ - inline void PfNodeCacheFlush(Node &) - { - } }; - -/** - * CYapfSegmentCostCacheLocalT - the yapf cost cache provider that implements fake segment - * cost caching functionality for yapf. Used when node needs caching, but you don't want to - * cache the segment costs. - */ -template -class CYapfSegmentCostCacheLocalT -{ -public: - typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class) - typedef typename Types::NodeList::Titem Node; ///< this will be our node type - typedef typename Node::Key Key; ///< key to hash tables - typedef typename Node::CachedData CachedData; - typedef typename CachedData::Key CacheKey; - using LocalCache = std::deque; - -protected: - LocalCache m_local_cache; - - /** to access inherited path finder */ - inline Tpf &Yapf() - { - return *static_cast(this); - } - -public: - /** - * Called by YAPF to attach cached or local segment cost data to the given node. - * @return true if globally cached data were used or false if local data was used - */ - inline bool PfNodeCacheFetch(Node &n) - { - CacheKey key(n.GetKey()); - Yapf().ConnectNodeToCachedData(n, m_local_cache.emplace_back(key)); - return false; - } - - /** - * Called by YAPF to flush the cached segment cost data back into cache storage. - * Current cache implementation doesn't use that. - */ - inline void PfNodeCacheFlush(Node &) - { - } -}; - - /** * Base class for segment cost cache providers. Contains global counter * of track layout changes and static notification function called whenever @@ -158,18 +102,19 @@ struct CSegmentCostCacheT : public CSegmentCostCacheBase { * segment cost caching services for your Nodes. */ template -class CYapfSegmentCostCacheGlobalT : public CYapfSegmentCostCacheLocalT { +class CYapfSegmentCostCacheGlobalT { public: - typedef CYapfSegmentCostCacheLocalT Tlocal; typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class) typedef typename Types::NodeList::Titem Node; ///< this will be our node type typedef typename Node::Key Key; ///< key to hash tables typedef typename Node::CachedData CachedData; typedef typename CachedData::Key CacheKey; typedef CSegmentCostCacheT Cache; + using LocalCache = std::deque; protected: Cache &m_global_cache; + LocalCache m_local_cache; inline CYapfSegmentCostCacheGlobalT() : m_global_cache(stGetGlobalCache()) {}; @@ -199,23 +144,18 @@ public: */ inline bool PfNodeCacheFetch(Node &n) { - if (!Yapf().CanUseGlobalCache(n)) { - return Tlocal::PfNodeCacheFetch(n); - } CacheKey key(n.GetKey()); + + if (!Yapf().CanUseGlobalCache(n)) { + Yapf().ConnectNodeToCachedData(n, m_local_cache.emplace_back(key)); + return false; + } + bool found; CachedData &item = m_global_cache.Get(key, &found); Yapf().ConnectNodeToCachedData(n, item); return found; } - - /** - * Called by YAPF to flush the cached segment cost data back into cache storage. - * Current cache implementation doesn't use that. - */ - inline void PfNodeCacheFlush(Node &) - { - } }; #endif /* YAPF_COSTCACHE_HPP */