java-topology/defects/ogre/patch/ogre-0001-node-queuedupdates-unordered-set.patch

48 lines
1.6 KiB
Diff

# UNDF: UNDF-2026-000000193
--- a/OgreMain/include/OgreNode.h
+++ b/OgreMain/include/OgreNode.h
@@ -28,6 +28,7 @@
#ifndef _Node_H__
#define _Node_H__
+#include <unordered_set>
#include "OgrePrerequisites.h"
#include "OgreMatrix4.h"
@@ -190,7 +191,7 @@ namespace Ogre {
/** Queue of nodes pending update. */
- typedef std::vector<Node*> QueuedUpdates;
+ typedef std::unordered_set<Node*> QueuedUpdates;
static QueuedUpdates msQueuedUpdates;
--- a/OgreMain/src/OgreNode.cpp
+++ b/OgreMain/src/OgreNode.cpp
@@ -71,12 +71,9 @@ namespace Ogre {
if (mQueuedForUpdate)
{
- // Erase from queued updates
- QueuedUpdates::iterator it =
- std::find(msQueuedUpdates.begin(), msQueuedUpdates.end(), this);
- assert(it != msQueuedUpdates.end());
- if (it != msQueuedUpdates.end())
- {
- // Optimised algorithm to erase an element from unordered vector.
- *it = msQueuedUpdates.back();
- msQueuedUpdates.pop_back();
- }
+ // O(1) erase — unordered_set, no linear scan needed
+ msQueuedUpdates.erase(this);
+ mQueuedForUpdate = false;
}
@@ -729,7 +720,7 @@ namespace Ogre {
void Node::queueNeedUpdate(Node* n)
{
// Don't queue the node more than once
if (!n->mQueuedForUpdate)
{
n->mQueuedForUpdate = true;
- msQueuedUpdates.push_back(n);
+ msQueuedUpdates.insert(n); // O(1) hash insert
}
}