summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-13 23:11:37 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-13 23:11:37 +0000
commitdec44e09b85c9c5bd1e87b1f9607429f046a1e64 (patch)
tree4250cd5b4cc945915fc712ddb4f8b73dcab99564 /src
parent137f1397f2298fab8b289cb040557a77f17b50fe (diff)
optimized a ton of strcmps down to an integer comparison!
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2385 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/commands.cpp17
-rw-r--r--src/helperfuncs.cpp2
-rw-r--r--src/message.cpp4
-rw-r--r--src/modules/m_spanningtree.cpp42
-rw-r--r--src/xline.cpp2
5 files changed, 32 insertions, 35 deletions
diff --git a/src/commands.cpp b/src/commands.cpp
index 55b95dc93..1c4f10470 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -314,7 +314,7 @@ void handle_kill(char **parameters, int pcnt, userrec *user)
return;
}
- if (strcmp(ServerName,u->server))
+ if (u->fd < 0)
{
// remote kill
WriteOpers("*** Remote kill by %s: %s!%s@%s (%s)",user->nick,u->nick,u->ident,u->host,parameters[1]);
@@ -505,7 +505,7 @@ void handle_topic(char **parameters, int pcnt, userrec *user)
topic[MAXTOPIC] = '\0';
}
- if (!strcasecmp(user->server,ServerName))
+ if (user->fd > -1)
{
int MOD_RESULT = 0;
FOREACH_RESULT(OnLocalTopicChange(user,Ptr,topic));
@@ -517,7 +517,7 @@ void handle_topic(char **parameters, int pcnt, userrec *user)
strlcpy(Ptr->setby,user->nick,NICKMAX);
Ptr->topicset = TIME;
WriteChannel(Ptr,user,"TOPIC %s :%s",Ptr->name, Ptr->topic);
- if (!strcasecmp(user->server,ServerName))
+ if (user->fd > -1)
{
FOREACH_MOD OnPostLocalTopicChange(user,Ptr,topic);
}
@@ -620,12 +620,10 @@ void handle_privmsg(char **parameters, int pcnt, userrec *user)
}
return;
}
-
- log(DEBUG,"*** PRIVMSG HANDLER");
+
dest = Find(parameters[0]);
if (dest)
{
- log(DEBUG,"*** FOUND NICK %s",dest->nick);
if (strcmp(dest->awaymsg,""))
{
/* auto respond with aweh msg */
@@ -641,10 +639,9 @@ void handle_privmsg(char **parameters, int pcnt, userrec *user)
}
parameters[1] = (char*)temp.c_str();
- if (!strcmp(dest->server,ServerName))
+ if (dest->server > -1)
{
// direct write, same server
- log(DEBUG,"*** CALL WRITETO");
WriteTo(user, dest, "PRIVMSG %s :%s", dest->nick, parameters[1]);
}
@@ -732,7 +729,7 @@ void handle_notice(char **parameters, int pcnt, userrec *user)
}
parameters[1] = (char*)temp.c_str();
- if (!strcmp(dest->server,ServerName))
+ if (dest->fd > -1)
{
// direct write, same server
WriteTo(user, dest, "NOTICE %s :%s", dest->nick, parameters[1]);
@@ -929,7 +926,7 @@ void handle_quit(char **parameters, int pcnt, userrec *user)
/* We should only prefix the quit for a local user. Remote users have
* already been prefixed, where neccessary, by the upstream server.
*/
- if (!strcasecmp(user->server,ServerName))
+ if (user->fd > -1)
{
Write(user->fd,"ERROR :Closing link (%s@%s) [%s%s]",user->ident,user->host,PrefixQuit,parameters[0]);
WriteOpers("*** Client exiting: %s!%s@%s [%s%s]",user->nick,user->ident,user->host,PrefixQuit,parameters[0]);
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 897f9f890..c4c6f397b 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -1133,7 +1133,7 @@ long local_count()
int c = 0;
for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
{
- if ((i->second->fd) && (isnick(i->second->nick)) && (!strcasecmp(i->second->server,ServerName))) c++;
+ if ((i->second->fd) && (isnick(i->second->nick)) && (i->second->server->fd > -1)) c++;
}
return c;
}
diff --git a/src/message.cpp b/src/message.cpp
index f55df0ee3..8c03e85f2 100644
--- a/src/message.cpp
+++ b/src/message.cpp
@@ -212,7 +212,7 @@ bool hasumode(userrec* user, char mode)
void ChangeName(userrec* user, const char* gecos)
{
- if (!strcasecmp(user->server,ServerName))
+ if (user->fd > -1)
{
int MOD_RESULT = 0;
FOREACH_RESULT(OnChangeLocalUserGECOS(user,gecos));
@@ -225,7 +225,7 @@ void ChangeName(userrec* user, const char* gecos)
void ChangeDisplayedHost(userrec* user, const char* host)
{
- if (!strcasecmp(user->server,ServerName))
+ if (user->fd > -1)
{
int MOD_RESULT = 0;
FOREACH_RESULT(OnChangeLocalUserHost(user,host));
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index 4a09ee476..daa7111ee 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -1405,7 +1405,7 @@ class TreeSocket : public InspSocket
if (params.size() == 1)
{
userrec* x = Srv->FindNick(params[0]);
- if (std::string(x->server) == Srv->GetServerName())
+ if (x->fd > -1)
{
userrec* x = Srv->FindNick(params[0]);
log(DEBUG,"Got IDLE");
@@ -1431,14 +1431,14 @@ class TreeSocket : public InspSocket
{
std::string who_did_the_whois = params[0];
userrec* who_to_send_to = Srv->FindNick(who_did_the_whois);
- if (std::string(who_to_send_to->server) == Srv->GetServerName())
+ if (who_to_send_to->fd > -1)
{
log(DEBUG,"Got final IDLE");
// an incoming reply to a whois we sent out
std::string nick_whoised = prefix;
unsigned long signon = atoi(params[1].c_str());
unsigned long idle = atoi(params[2].c_str());
- if ((who_to_send_to) && (std::string(who_to_send_to->server) == Srv->GetServerName()))
+ if ((who_to_send_to) && (who_to_send_to->fd > -1))
do_whois(who_to_send_to,u,signon,idle,(char*)nick_whoised.c_str());
}
else
@@ -1962,7 +1962,7 @@ void GetListOfServersForChannel(chanrec* c, std::deque<TreeServer*> &list)
{
char* o = (*ulist)[i];
userrec* otheruser = (userrec*)o;
- if (std::string(otheruser->server) != Srv->GetServerName())
+ if (otheruser->fd < 0)
{
TreeServer* best = BestRouteTo(otheruser->server);
if (best)
@@ -2318,10 +2318,10 @@ class ModuleSpanningTree : public Module
int HandleRemoteWhois(char** parameters, int pcnt, userrec* user)
{
- if ((std::string(user->server) == Srv->GetServerName()) && (pcnt > 1))
+ if ((user->fd > -1) && (pcnt > 1))
{
userrec* remote = Srv->FindNick(parameters[1]);
- if ((remote) && (std::string(remote->server) != Srv->GetServerName()))
+ if ((remote) && (remote->fd < 0))
{
std::deque<std::string> params;
params.push_back(parameters[1]);
@@ -2521,7 +2521,7 @@ class ModuleSpanningTree : public Module
virtual void OnUserInvite(userrec* source,userrec* dest,chanrec* channel)
{
- if (std::string(source->server) == Srv->GetServerName())
+ if (source->fd > -1)
{
std::deque<std::string> params;
params.push_back(dest->nick);
@@ -2540,7 +2540,7 @@ class ModuleSpanningTree : public Module
virtual void OnWallops(userrec* user, std::string text)
{
- if (std::string(user->server) == Srv->GetServerName())
+ if (user->fd > -1)
{
std::deque<std::string> params;
params.push_back(":"+text);
@@ -2553,7 +2553,7 @@ class ModuleSpanningTree : public Module
if (target_type == TYPE_USER)
{
userrec* d = (userrec*)dest;
- if ((std::string(d->server) != Srv->GetServerName()) && (std::string(user->server) == Srv->GetServerName()))
+ if ((d->fd < 0) && (user->fd > -1))
{
std::deque<std::string> params;
params.clear();
@@ -2564,7 +2564,7 @@ class ModuleSpanningTree : public Module
}
else
{
- if (std::string(user->server) == Srv->GetServerName())
+ if (user->fd > -1)
{
chanrec *c = (chanrec*)dest;
std::deque<TreeServer*> list;
@@ -2587,7 +2587,7 @@ class ModuleSpanningTree : public Module
// route private messages which are targetted at clients only to the server
// which needs to receive them
userrec* d = (userrec*)dest;
- if ((std::string(d->server) != Srv->GetServerName()) && (std::string(user->server) == Srv->GetServerName()))
+ if ((d->fd < 0) && (user->fd > -1))
{
std::deque<std::string> params;
params.clear();
@@ -2598,7 +2598,7 @@ class ModuleSpanningTree : public Module
}
else
{
- if (std::string(user->server) == Srv->GetServerName())
+ if (user->fd > -1)
{
chanrec *c = (chanrec*)dest;
std::deque<TreeServer*> list;
@@ -2623,7 +2623,7 @@ class ModuleSpanningTree : public Module
virtual void OnUserJoin(userrec* user, chanrec* channel)
{
// Only do this for local users
- if (std::string(user->server) == Srv->GetServerName())
+ if (user->fd > -1)
{
std::deque<std::string> params;
params.clear();
@@ -2675,7 +2675,7 @@ class ModuleSpanningTree : public Module
virtual void OnUserPart(userrec* user, chanrec* channel)
{
- if (std::string(user->server) == Srv->GetServerName())
+ if (user->fd > -1)
{
std::deque<std::string> params;
params.push_back(channel->name);
@@ -2686,7 +2686,7 @@ class ModuleSpanningTree : public Module
virtual void OnUserConnect(userrec* user)
{
char agestr[MAXBUF];
- if (std::string(user->server) == Srv->GetServerName())
+ if (user->fd > -1)
{
std::deque<std::string> params;
snprintf(agestr,MAXBUF,"%lu",(unsigned long)user->age);
@@ -2704,7 +2704,7 @@ class ModuleSpanningTree : public Module
virtual void OnUserQuit(userrec* user, std::string reason)
{
- if ((std::string(user->server) == Srv->GetServerName()) && (user->registered == 7))
+ if ((user->fd > -1) && (user->registered == 7))
{
std::deque<std::string> params;
params.push_back(":"+reason);
@@ -2714,7 +2714,7 @@ class ModuleSpanningTree : public Module
virtual void OnUserPostNick(userrec* user, std::string oldnick)
{
- if (std::string(user->server) == Srv->GetServerName())
+ if (user->fd > -1)
{
std::deque<std::string> params;
params.push_back(user->nick);
@@ -2724,7 +2724,7 @@ class ModuleSpanningTree : public Module
virtual void OnUserKick(userrec* source, userrec* user, chanrec* chan, std::string reason)
{
- if (std::string(source->server) == Srv->GetServerName())
+ if (source->server > -1)
{
std::deque<std::string> params;
params.push_back(chan->name);
@@ -2764,7 +2764,7 @@ class ModuleSpanningTree : public Module
// locally.
virtual void OnOper(userrec* user, std::string opertype)
{
- if (std::string(user->server) == Srv->GetServerName())
+ if (user->fd > -1)
{
std::deque<std::string> params;
params.push_back(opertype);
@@ -2774,7 +2774,7 @@ class ModuleSpanningTree : public Module
void OnLine(userrec* source, std::string host, bool adding, char linetype, long duration, std::string reason)
{
- if (std::string(source->server) == Srv->GetServerName())
+ if (source->fd > -1)
{
char type[8];
snprintf(type,8,"%cLINE",linetype);
@@ -2840,7 +2840,7 @@ class ModuleSpanningTree : public Module
virtual void OnMode(userrec* user, void* dest, int target_type, std::string text)
{
- if ((std::string(user->server) == Srv->GetServerName()) && (user->registered == 7))
+ if ((user->fd > -1) && (user->registered == 7))
{
if (target_type == TYPE_USER)
{
diff --git a/src/xline.cpp b/src/xline.cpp
index ffe38c94d..434aaeeb1 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -702,7 +702,7 @@ void apply_lines()
go_again = false;
for (user_hash::const_iterator u = clientlist.begin(); u != clientlist.end(); u++)
{
- if (!strcasecmp(u->second->server,ServerName))
+ if (u->second->server > -1)
{
snprintf(host,MAXBUF,"%s@%s",u->second->ident,u->second->host);
if (elines.size())