summaryrefslogtreecommitdiff
path: root/src/coremods/core_whowas.cpp
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2015-11-23 11:42:49 +0100
committerAttila Molnar <attilamolnar@hush.com>2015-11-23 11:42:49 +0100
commit133b7fade64bd0ab9360dd0998b0d5ad170e230b (patch)
tree93b094917639fe0e6ce094929d7473fddf9eb808 /src/coremods/core_whowas.cpp
parentbf2f81811fe1869a98861b2d5edc0fba8f884123 (diff)
core_whowas Purge nicks as soon as they no longer have any entries
Diffstat (limited to 'src/coremods/core_whowas.cpp')
-rw-r--r--src/coremods/core_whowas.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/coremods/core_whowas.cpp b/src/coremods/core_whowas.cpp
index 12ab940dd..79ce94cc9 100644
--- a/src/coremods/core_whowas.cpp
+++ b/src/coremods/core_whowas.cpp
@@ -76,11 +76,7 @@ const WhoWas::Nick* WhoWas::Manager::FindNick(const std::string& nickname) const
whowas_users::const_iterator it = whowas.find(nickname);
if (it == whowas.end())
return NULL;
-
- const Nick* nick = it->second;
- if (nick->entries.empty())
- return NULL;
- return nick;
+ return it->second;
}
WhoWas::Manager::Stats WhoWas::Manager::GetStats() const
@@ -153,7 +149,7 @@ void WhoWas::Manager::Prune()
}
/* Then cut the whowas sets to new size (groupsize) */
- for (whowas_users::iterator i = whowas.begin(); i != whowas.end(); ++i)
+ for (whowas_users::iterator i = whowas.begin(); i != whowas.end(); )
{
WhoWas::Nick::List& list = i->second->entries;
while (list.size() > this->GroupSize)
@@ -161,6 +157,11 @@ void WhoWas::Manager::Prune()
delete list.front();
list.pop_front();
}
+
+ if (list.empty())
+ PurgeNick(i++);
+ else
+ ++i;
}
}
@@ -168,7 +169,7 @@ void WhoWas::Manager::Prune()
void WhoWas::Manager::Maintain()
{
time_t min = ServerInstance->Time() - this->MaxKeep;
- for (whowas_users::iterator i = whowas.begin(); i != whowas.end(); ++i)
+ for (whowas_users::iterator i = whowas.begin(); i != whowas.end(); )
{
WhoWas::Nick::List& list = i->second->entries;
while (!list.empty() && list.front()->signon < min)
@@ -176,6 +177,11 @@ void WhoWas::Manager::Maintain()
delete list.front();
list.pop_front();
}
+
+ if (list.empty())
+ PurgeNick(i++);
+ else
+ ++i;
}
}