From 23ad4ec8797044e11b96d222c3f97d4e96cb6b55 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Fri, 4 Oct 2019 02:12:45 +0100 Subject: [PATCH] YAPF: Reduce need to scan open list queue when moving best node to closed list --- src/pathfinder/yapf/nodelist.hpp | 16 ++++++++++++++++ src/pathfinder/yapf/yapf_base.hpp | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/pathfinder/yapf/nodelist.hpp b/src/pathfinder/yapf/nodelist.hpp index 45a72efd5e..3cc7683b16 100644 --- a/src/pathfinder/yapf/nodelist.hpp +++ b/src/pathfinder/yapf/nodelist.hpp @@ -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) { diff --git a/src/pathfinder/yapf/yapf_base.hpp b/src/pathfinder/yapf/yapf_base.hpp index 7b792e6c18..16b5f73bb1 100644 --- a/src/pathfinder/yapf/yapf_base.hpp +++ b/src/pathfinder/yapf/yapf_base.hpp @@ -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; }