Codechange: Removed unused yapf PfNodeCachFlush function

This commit is contained in:
Koen Bussemaker 2024-05-25 11:33:53 +02:00 committed by Kuhnovic
parent d72917b285
commit 6efc1fa250
2 changed files with 10 additions and 74 deletions

View File

@ -227,10 +227,6 @@ public:
bool bValid = Yapf().PfCalcCost(n, &tf); bool bValid = Yapf().PfCalcCost(n, &tf);
if (bCached) {
Yapf().PfNodeCacheFlush(n);
}
if (bValid) bValid = Yapf().PfCalcEstimate(n); if (bValid) bValid = Yapf().PfCalcEstimate(n);
/* have the cost or estimate callbacks marked this node as invalid? */ /* have the cost or estimate callbacks marked this node as invalid? */

View File

@ -14,7 +14,7 @@
/** /**
* CYapfSegmentCostCacheNoneT - the formal only yapf cost cache provider that implements * 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). * defined (they don't count with any segment cost caching).
*/ */
template <class Types> template <class Types>
@ -32,64 +32,8 @@ public:
{ {
return false; 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 Types>
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<CachedData>;
protected:
LocalCache m_local_cache;
/** to access inherited path finder */
inline Tpf &Yapf()
{
return *static_cast<Tpf *>(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 * Base class for segment cost cache providers. Contains global counter
* of track layout changes and static notification function called whenever * 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. * segment cost caching services for your Nodes.
*/ */
template <class Types> template <class Types>
class CYapfSegmentCostCacheGlobalT : public CYapfSegmentCostCacheLocalT<Types> { class CYapfSegmentCostCacheGlobalT {
public: public:
typedef CYapfSegmentCostCacheLocalT<Types> Tlocal;
typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class) 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 Types::NodeList::Titem Node; ///< this will be our node type
typedef typename Node::Key Key; ///< key to hash tables typedef typename Node::Key Key; ///< key to hash tables
typedef typename Node::CachedData CachedData; typedef typename Node::CachedData CachedData;
typedef typename CachedData::Key CacheKey; typedef typename CachedData::Key CacheKey;
typedef CSegmentCostCacheT<CachedData> Cache; typedef CSegmentCostCacheT<CachedData> Cache;
using LocalCache = std::deque<CachedData>;
protected: protected:
Cache &m_global_cache; Cache &m_global_cache;
LocalCache m_local_cache;
inline CYapfSegmentCostCacheGlobalT() : m_global_cache(stGetGlobalCache()) {}; inline CYapfSegmentCostCacheGlobalT() : m_global_cache(stGetGlobalCache()) {};
@ -199,23 +144,18 @@ public:
*/ */
inline bool PfNodeCacheFetch(Node &n) inline bool PfNodeCacheFetch(Node &n)
{ {
if (!Yapf().CanUseGlobalCache(n)) {
return Tlocal::PfNodeCacheFetch(n);
}
CacheKey key(n.GetKey()); CacheKey key(n.GetKey());
if (!Yapf().CanUseGlobalCache(n)) {
Yapf().ConnectNodeToCachedData(n, m_local_cache.emplace_back(key));
return false;
}
bool found; bool found;
CachedData &item = m_global_cache.Get(key, &found); CachedData &item = m_global_cache.Get(key, &found);
Yapf().ConnectNodeToCachedData(n, item); Yapf().ConnectNodeToCachedData(n, item);
return found; 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 */ #endif /* YAPF_COSTCACHE_HPP */