mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-04 06:00:15 +00:00
YAPF: Reduce need to scan open list queue when moving best node to closed list
This commit is contained in:
parent
33f5e00700
commit
23ad4ec879
@ -110,6 +110,22 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline void DequeueBestOpenNode()
|
||||
{
|
||||
assert(!m_open_queue.IsEmpty());
|
||||
m_open_queue.Shift();
|
||||
}
|
||||
|
||||
inline void ReenqueueOpenNode(Titem_ &item)
|
||||
{
|
||||
m_open_queue.Include(&item);
|
||||
}
|
||||
|
||||
inline Titem_& PopAlreadyDequeuedOpenNode(const Key &key)
|
||||
{
|
||||
return m_open.Pop(key);
|
||||
}
|
||||
|
||||
/** return the open node specified by a key or nullptr if not found */
|
||||
inline Titem_ *FindOpenNode(const Key &key)
|
||||
{
|
||||
|
@ -140,11 +140,13 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
m_nodes.DequeueBestOpenNode();
|
||||
Yapf().PfFollowNode(*n);
|
||||
if (m_max_search_nodes == 0 || m_nodes.ClosedCount() < m_max_search_nodes) {
|
||||
m_nodes.PopOpenNode(n->GetKey());
|
||||
m_nodes.PopAlreadyDequeuedOpenNode(n->GetKey());
|
||||
m_nodes.InsertClosedNode(*n);
|
||||
} else {
|
||||
m_nodes.ReenqueueOpenNode(*n);
|
||||
bDestFound = false;
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user