mirror of
https://github.com/znc/znc.git
synced 2026-05-08 06:14:40 +02:00
CUser: Save CIRCSock* instead of looking it up every time
Via profiling ZNC it was found that much CPU time was spent inside FindSockByName() which in turn was called by CUser::GetIRCSock(): w00t volunteered to write a patch to save that pointer inside CUser and here is the result. Thanks. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1053 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "znc.h"
|
||||
|
||||
CUser::CUser(const CString& sUserName) {
|
||||
m_pIRCSock = NULL;
|
||||
m_fTimezoneOffset = 0;
|
||||
m_uConnectTime = 0;
|
||||
SetUserName(sUserName);
|
||||
@@ -105,6 +106,8 @@ void CUser::DelServers()
|
||||
}
|
||||
|
||||
void CUser::IRCConnected(CIRCSock* pIRCSock) {
|
||||
m_pIRCSock = pIRCSock;
|
||||
|
||||
for (unsigned int a = 0; a < m_vClients.size(); a++) {
|
||||
m_vClients[a]->IRCConnected(pIRCSock);
|
||||
}
|
||||
@@ -113,6 +116,8 @@ void CUser::IRCConnected(CIRCSock* pIRCSock) {
|
||||
void CUser::IRCDisconnected() {
|
||||
m_bIRCConnected = false;
|
||||
|
||||
m_pIRCSock = NULL;
|
||||
|
||||
for (unsigned int a = 0; a < m_vClients.size(); a++) {
|
||||
m_vClients[a]->IRCDisconnected();
|
||||
}
|
||||
@@ -802,13 +807,11 @@ bool CUser::CheckPass(const CString& sPass) {
|
||||
}*/
|
||||
|
||||
CIRCSock* CUser::GetIRCSock() {
|
||||
// Todo: optimize this by saving a pointer to the sock
|
||||
return (CIRCSock*) CZNC::Get().GetManager().FindSockByName("IRC::" + m_sUserName);
|
||||
return m_pIRCSock;
|
||||
}
|
||||
|
||||
const CIRCSock* CUser::GetIRCSock() const {
|
||||
// Todo: same as above
|
||||
return (CIRCSock*) CZNC::Get().GetManager().FindSockByName("IRC::" + m_sUserName);
|
||||
return m_pIRCSock;
|
||||
}
|
||||
|
||||
CString CUser::GetLocalIP() {
|
||||
|
||||
Reference in New Issue
Block a user