diff options
author | Adam <Adam@anope.org> | 2013-08-07 17:27:09 +0000 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-08-07 17:27:18 +0000 |
commit | 7f1b5552dc4ddccb688120d66946601fa695b650 (patch) | |
tree | 34dfa3475b9dcabce5a6e5713cbbc348a45cbd09 /include/modules.h | |
parent | 4865a8cfff2fb2ab3acba89c5aabbb5f0db80743 (diff) |
Shrink to fit module event vectors when modules are removed from them
Diffstat (limited to 'include/modules.h')
-rw-r--r-- | include/modules.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/modules.h b/include/modules.h index 14661d1c7..aef6d7d30 100644 --- a/include/modules.h +++ b/include/modules.h @@ -63,6 +63,7 @@ if (true) \ { \ static std::vector<Module *> &_modules = ModuleManager::GetEventHandlers(#ename); \ + bool _shrink = false; \ for (std::vector<Module *>::iterator _i = _modules.begin(); _i != _modules.end();) \ { \ try \ @@ -76,10 +77,13 @@ if (true) \ catch (const NotImplementedException &) \ { \ _i = _modules.erase(_i); \ + _shrink = true; \ continue; \ } \ ++_i; \ } \ + if (_shrink) \ + std::vector<Module *>(_modules).swap(_modules); \ } \ else \ static_cast<void>(0) @@ -97,6 +101,7 @@ if (true) \ { \ ret = EVENT_CONTINUE; \ static std::vector<Module *> &_modules = ModuleManager::GetEventHandlers(#ename); \ + bool _shrink = false; \ for (std::vector<Module *>::iterator _i = _modules.begin(); _i != _modules.end();) \ { \ try \ @@ -115,10 +120,13 @@ if (true) \ catch (const NotImplementedException &) \ { \ _i = _modules.erase(_i); \ + _shrink = true; \ continue; \ } \ ++_i; \ } \ + if (_shrink) \ + std::vector<Module *>(_modules).swap(_modules); \ } \ else \ static_cast<void>(0) |