summaryrefslogtreecommitdiff
path: root/src/helperfuncs.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-29 23:34:47 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-29 23:34:47 +0000
commit5e9a6b9186a8cbaaf65ae7d9cd9c0c033c91b497 (patch)
tree5e90ee569ad974e0affe96d02b3470345eb74192 /src/helperfuncs.cpp
parentb848ca14335adcb924acb7977d93e0d76b9437b7 (diff)
Add counter system for umodes to get rid of some O(n)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6163 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/helperfuncs.cpp')
-rw-r--r--src/helperfuncs.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index fdbeb613f..84cc52df5 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -308,28 +308,24 @@ int InspIRCd::RegisteredUserCount()
return clientlist->size() - this->UnregisteredUserCount();
}
-int InspIRCd::InvisibleUserCount()
+int InspIRCd::ModeCount(const char mode)
{
- int c = 0;
+ ModeHandler* mh = this->Modes->GetHandler(mode, MODETYPE_USER);
- for (user_hash::const_iterator i = clientlist->begin(); i != clientlist->end(); i++)
- {
- c += ((i->second->registered == REG_ALL) && (i->second->modes[UM_INVISIBLE]));
- }
+ if (mh)
+ return mh->GetCount();
+ else
+ return 0;
+}
- return c;
+int InspIRCd::InvisibleUserCount()
+{
+ return ModeCount('i');
}
int InspIRCd::OperCount()
{
- int c = 0;
-
- for (user_hash::const_iterator i = clientlist->begin(); i != clientlist->end(); i++)
- {
- if (*(i->second->oper))
- c++;
- }
- return c;
+ return ModeCount('o');
}
int InspIRCd::UnregisteredUserCount()