mirror of
https://github.com/znc/znc.git
synced 2026-07-31 14:03:00 +02:00
Avoid a possibly expensive FindSockByName() for finding IRC socks
While a user is connecting to an IRC server, the CUser instance didn't know about the CIRCSock instance (due to historic reasons). This meant that we needed to use FindSockByName() when we had to check if there is any CIRCSock associated with this user. However, this is a bad idea since FindSockByName() is O(n) on the number of sockets that the socket manager is managing. Instead, we now already set CUser::m_pIRCSock when the CIRCSock is created so that checking for an irc socket becomes O(1). This was inspired by the results of profiling a znc instance with 900 users. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2171 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -157,10 +157,23 @@ void CUser::DelServers()
|
||||
m_vServers.clear();
|
||||
}
|
||||
|
||||
void CUser::IRCConnected(CIRCSock* pIRCSock) {
|
||||
void CUser::SetIRCSocket(CIRCSock* pIRCSock) {
|
||||
m_pIRCSock = pIRCSock;
|
||||
}
|
||||
|
||||
bool CUser::IsIRCConnected() const
|
||||
{
|
||||
const CIRCSock* pSock = GetIRCSock();
|
||||
|
||||
if (!pSock)
|
||||
return false;
|
||||
|
||||
if (!pSock->IsConnected())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CUser::IRCDisconnected() {
|
||||
m_pIRCSock = NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user