From: brain Date: Fri, 6 Oct 2006 07:51:44 +0000 (+0000) Subject: Tidy up m_safelist to avoid strlen on every line output, we're strlen()ing a constant... X-Git-Tag: v2.0.23~6935 X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=b13975318539561a39624e95ee41c32f2f749663;p=user%2Fhenk%2Fcode%2Finspircd.git Tidy up m_safelist to avoid strlen on every line output, we're strlen()ing a constant-ish string so instead record the value for later use. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5425 e03df62e-2008-0410-955e-edbf42e46eb7 --- diff --git a/src/modules/m_safelist.cpp b/src/modules/m_safelist.cpp index da4635442..9008e485a 100644 --- a/src/modules/m_safelist.cpp +++ b/src/modules/m_safelist.cpp @@ -55,11 +55,13 @@ class ListTimer : public InspTimer chanrec *chan; InspIRCd* ServerInstance; const std::string glob; + size_t ServerNameSize; public: ListTimer(InspIRCd* Instance, long interval) : InspTimer(interval,Instance->Time()), ServerInstance(Instance) { + ServerNameSize = 4 + strlen(ServerInstance->Config->ServerName); } virtual void Tick(time_t TIME) @@ -92,7 +94,7 @@ class ListTimer : public InspTimer ServerInstance->Log(DEBUG, "m_safelist.so: resuming spool of list to client %s at channel %ld", u->nick, ld->list_position); chan = NULL; - /* Attempt to fill up to half the user's sendq with /LIST output */ + /* Attempt to fill up to 25% the user's sendq with /LIST output */ long amount_sent = 0; do { @@ -105,14 +107,14 @@ class ListTimer : public InspTimer if ((chan) && (((!(chan->modes[CM_PRIVATE])) && (!(chan->modes[CM_SECRET]))) || (has_user))) { bool display = match(chan->name, ld->glob.c_str()); - long users = chan->GetUserCounter(); + if ((users) && (display)) { - int counter = snprintf(buffer,MAXBUF,"322 %s %s %ld :[+%s] %s",u->nick,chan->name,users,chan->ChanModes(has_user),chan->topic); + int counter = snprintf(buffer, MAXBUF, "322 %s %s %ld :[+%s] %s",u->nick, chan->name, users, chan->ChanModes(has_user), chan->topic); /* Increment total plus linefeed */ - amount_sent += counter + 4 + strlen(ServerInstance->Config->ServerName); - ServerInstance->Log(DEBUG,"m_safelist.so: Sent %ld of safe %ld / 4",amount_sent,u->sendqmax); + amount_sent += counter + ServerNameSize; + ServerInstance->Log(DEBUG, "m_safelist.so: Sent %ld of safe %ld / 4", amount_sent, u->sendqmax); u->WriteServ(std::string(buffer)); } }