summaryrefslogtreecommitdiff
path: root/src/users.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-30 15:11:40 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-30 15:11:40 +0000
commit6fff3c54be91dbbfe5e3ffca4204ad0378d70b7d (patch)
tree7c10778fc957a26c2e9b00882459e163aa548f40 /src/users.cpp
parentfce2d243c023660a9afbf01143cde6eda2ec7a88 (diff)
Tons of optimization of WriteChannel, WriteChannelWithServ, WriteCommon etc, dont call userrec::GetFullHost or snprintf for every item, call it just once.
Turns O(n) calls for every write into O(~1) calls per write. Remove some debug from the socketengines which makes debugging hard on large channels (write availability message) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6171 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/users.cpp')
-rw-r--r--src/users.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/users.cpp b/src/users.cpp
index e4f63e3ba..e3c432caf 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1560,11 +1560,15 @@ void userrec::WriteCommon(const std::string &text)
try
{
bool sent_to_at_least_one = false;
+ char tb[MAXBUF];
if (this->registered != REG_ALL)
return;
uniq_id++;
+
+ /* We dont want to be doing this n times, just once */
+ snprintf(tb,MAXBUF,":%s %s",this->GetFullHost(),text.c_str());
for (UCListIter v = this->chans.begin(); v != this->chans.end(); v++)
{
@@ -1574,7 +1578,7 @@ void userrec::WriteCommon(const std::string &text)
if ((IS_LOCAL(i->second)) && (already_sent[i->second->fd] != uniq_id))
{
already_sent[i->second->fd] = uniq_id;
- i->second->WriteFrom(this, std::string(text));
+ i->second->Write(std::string(tb));
sent_to_at_least_one = true;
}
}
@@ -1586,7 +1590,7 @@ void userrec::WriteCommon(const std::string &text)
*/
if (!sent_to_at_least_one)
{
- this->WriteFrom(this,std::string(text));
+ this->WriteFrom(this,std::string(tb));
}
}
@@ -1618,6 +1622,8 @@ void userrec::WriteCommonExcept(const std::string &text)
bool quit_munge = false;
char oper_quit[MAXBUF];
char textbuffer[MAXBUF];
+ char tb1[MAXBUF];
+ char tb2[MAXBUF];
strlcpy(textbuffer, text.c_str(), MAXBUF);
@@ -1626,6 +1632,8 @@ void userrec::WriteCommonExcept(const std::string &text)
uniq_id++;
+ snprintf(tb1,MAXBUF,":%s %s",this->GetFullHost(),textbuffer);
+
/* TODO: We need some form of WriteCommonExcept that will send two lines, one line to
* opers and the other line to non-opers, then all this hidebans and hidesplits gunk
* can go byebye.
@@ -1648,6 +1656,7 @@ void userrec::WriteCommonExcept(const std::string &text)
strlcpy(oper_quit,textbuffer,MAXQUIT);
strlcpy(check,"*.net *.split",MAXQUIT);
quit_munge = true;
+ snprintf(tb2,MAXBUF,":%s %s",this->GetFullHost(),oper_quit);
}
}
}
@@ -1661,6 +1670,7 @@ void userrec::WriteCommonExcept(const std::string &text)
strlcpy(oper_quit,textbuffer,MAXQUIT);
*check = 0; // We don't need to strlcpy, we just chop it from the :
quit_munge = true;
+ snprintf(tb2,MAXBUF,":%s %s",this->GetFullHost(),oper_quit);
}
}
@@ -1675,9 +1685,9 @@ void userrec::WriteCommonExcept(const std::string &text)
{
already_sent[i->second->fd] = uniq_id;
if (quit_munge)
- i->second->WriteFrom(this, *i->second->oper ? std::string(oper_quit) : std::string(textbuffer));
+ i->second->Write(*i->second->oper ? std::string(tb2) : std::string(tb1));
else
- i->second->WriteFrom(this, std::string(textbuffer));
+ i->second->Write(std::string(tb1));
}
}
}