diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-10-07 12:40:35 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-10-29 17:16:37 +0100 |
commit | 93ad5ec32de124dfa0c054acfd1f2a378cb9ca75 (patch) | |
tree | bfe8e842a780cd87ee105806f4112e01784ff7fc /src/configuration.h | |
parent | 63fffadacc51fb7c4915361f0286682e08a55cb1 (diff) | |
download | mana-93ad5ec32de124dfa0c054acfd1f2a378cb9ca75.tar.gz mana-93ad5ec32de124dfa0c054acfd1f2a378cb9ca75.tar.bz2 mana-93ad5ec32de124dfa0c054acfd1f2a378cb9ca75.tar.xz mana-93ad5ec32de124dfa0c054acfd1f2a378cb9ca75.zip |
Optimise PlayerRelationsManager::clear
Previous implementation was O(n^2), doing lots of work (saving file and
updating UI) for each removed player.
Diffstat (limited to 'src/configuration.h')
-rw-r--r-- | src/configuration.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/configuration.h b/src/configuration.h index a22eb258..a26c6e20 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -53,7 +53,7 @@ class ConfigurationListManager * \return obj, or otherwise NULL to indicate that this option should * be skipped */ - virtual ConfigurationObject *writeConfigItem(T value, + virtual ConfigurationObject *writeConfigItem(const T &value, ConfigurationObject *obj) = 0; /** @@ -124,7 +124,7 @@ class ConfigurationObject */ template <class IT, class T, class CONT> void setList(const std::string &name, IT begin, IT end, - ConfigurationListManager<T, CONT> *manager) + ConfigurationListManager<T, CONT> &manager) { auto *nextobj = new ConfigurationObject; std::list<ConfigurationObject *> &list = mContainerOptions[name]; @@ -132,7 +132,7 @@ class ConfigurationObject for (IT it = begin; it != end; it++) { - ConfigurationObject *wrobj = manager->writeConfigItem(*it, nextobj); + ConfigurationObject *wrobj = manager.writeConfigItem(*it, nextobj); if (wrobj) { // wrote something assert (wrobj == nextobj); @@ -160,12 +160,12 @@ class ConfigurationObject * \param manager An object capable of deserialising items into CONT */ template<class T, class CONT> - CONT getList(const std::string &name, CONT empty, ConfigurationListManager<T, CONT> *manager) + CONT getList(const std::string &name, CONT empty, ConfigurationListManager<T, CONT> &manager) { CONT container = empty; for (auto obj : mContainerOptions[name]) - container = manager->readConfigItem(obj, container); + container = manager.readConfigItem(obj, container); return container; } |