Use unordered_map to store sessions for performance reasons

This commit is contained in:
Tim Wojtulewicz 2021-07-28 14:04:34 -07:00
parent 2a717e05cc
commit e2dc6df8a2
4 changed files with 36 additions and 4 deletions

View file

@ -218,9 +218,17 @@ void Manager::Insert(Session* s, bool remove_existing)
void Manager::Drain()
{
for ( const auto& entry : session_map )
std::vector<const detail::Key*> keys;
keys.reserve(session_map.size());
for ( auto& entry : session_map )
keys.push_back(&(entry.first));
std::sort(keys.begin(), keys.end(), [](const detail::Key* a, const detail::Key* b) {
return *a < *b; });
for ( const auto* k : keys )
{
Session* tc = entry.second;
Session* tc = session_map.at(*k);
tc->Done();
tc->RemovalEvent();
}