diff options
author | max-001 <maxsmits21@kpnmail.nl> | 2024-11-26 09:20:55 +0100 |
---|---|---|
committer | max-001 <maxsmits21@kpnmail.nl> | 2024-11-26 09:20:55 +0100 |
commit | f52e7e1450d47604983dba5f3cbab364ffd77cdc (patch) | |
tree | 8c084f84605272e4092736152bb1f92bc781c68b /src/crepe | |
parent | 41df3ad8836ce9c686a12fa7da5b4daebe94ba05 (diff) |
Replaced vector by unordered_map
Diffstat (limited to 'src/crepe')
-rw-r--r-- | src/crepe/ComponentManager.cpp | 8 | ||||
-rw-r--r-- | src/crepe/ComponentManager.h | 2 |
2 files changed, 1 insertions, 9 deletions
diff --git a/src/crepe/ComponentManager.cpp b/src/crepe/ComponentManager.cpp index a90502d..e99419e 100644 --- a/src/crepe/ComponentManager.cpp +++ b/src/crepe/ComponentManager.cpp @@ -39,19 +39,11 @@ GameObject ComponentManager::new_object(const string & name, const string & tag, // Find the first available id (taking persistent objects into account) while (this->persistent[this->next_id]) { this->next_id++; - // Make sure that the persistent vector is large enough - if (persistent.size() <= next_id) { - this->persistent.resize(next_id + 1, false); - } } GameObject object{*this, this->next_id, name, tag, position, rotation, scale}; this->next_id++; - // Make sure that the persistent vector is large enough - if (persistent.size() <= next_id) { - this->persistent.resize(next_id + 1, false); - } return object; } diff --git a/src/crepe/ComponentManager.h b/src/crepe/ComponentManager.h index 810bc38..8462698 100644 --- a/src/crepe/ComponentManager.h +++ b/src/crepe/ComponentManager.h @@ -147,7 +147,7 @@ private: components; //! Persistent flag for each GameObject - std::vector<bool> persistent = {false}; + std::unordered_map<game_object_id_t, bool> persistent; //! ID of next GameObject allocated by \c ComponentManager::new_object game_object_id_t next_id = 0; |