summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-02-18 00:50:09 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-02-18 00:50:09 +0000
commit13fcf22eaba873290e0f04484fc75bcd339d4fa3 (patch)
treed977e708f37437aa40914b6cb00dff717e9d8679
parent23d635950d15eea741e41af6b3109ccfc3196cb6 (diff)
Eliminate some string copies, tidy some code, and reverse some short-circuit checks
(Expensive(x) && Cheap(y)) -> (Cheap(y) && Expensive(x)) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6591 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/cmd_notice.cpp2
-rw-r--r--src/cmd_privmsg.cpp2
-rw-r--r--src/modules/m_dccallow.cpp13
-rw-r--r--src/modules/m_restrictbanned.cpp2
-rw-r--r--src/modules/m_services.cpp2
-rw-r--r--src/modules/m_services_account.cpp2
-rw-r--r--src/modules/m_silence_ext.cpp12
-rw-r--r--src/modules/m_stripcolor.cpp15
8 files changed, 16 insertions, 34 deletions
diff --git a/src/cmd_notice.cpp b/src/cmd_notice.cpp
index 8d0aecef0..7ce2d93c5 100644
--- a/src/cmd_notice.cpp
+++ b/src/cmd_notice.cpp
@@ -88,7 +88,7 @@ CmdResult cmd_notice::Handle (const char** parameters, int pcnt, userrec *user)
}
parameters[1] = temp.c_str();
- if (temp == "")
+ if (temp.empty())
{
user->WriteServ("412 %s No text to send", user->nick);
return CMD_FAILURE;
diff --git a/src/cmd_privmsg.cpp b/src/cmd_privmsg.cpp
index 26e63dfb9..d83e71662 100644
--- a/src/cmd_privmsg.cpp
+++ b/src/cmd_privmsg.cpp
@@ -90,7 +90,7 @@ CmdResult cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user)
}
parameters[1] = temp.c_str();
- if (temp == "")
+ if (temp.empty())
{
user->WriteServ("412 %s No text to send", user->nick);
return CMD_FAILURE;
diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp
index 18330e357..193d569dd 100644
--- a/src/modules/m_dccallow.cpp
+++ b/src/modules/m_dccallow.cpp
@@ -307,8 +307,6 @@ class ModuleDCCAllow : public Module
if (!IS_LOCAL(user))
return 0;
- Expire();
-
if (target_type == TYPE_USER)
{
userrec* u = (userrec*)dest;
@@ -319,6 +317,9 @@ class ModuleDCCAllow : public Module
if ((text.length()) && (text[0] == '\1'))
{
+
+ Expire();
+
// :jamie!jamie@test-D4457903BA652E0F.silverdream.org PRIVMSG eimaj :DCC SEND m_dnsbl.cpp 3232235786 52650 9676
// :jamie!jamie@test-D4457903BA652E0F.silverdream.org PRIVMSG eimaj :VERSION
@@ -358,25 +359,19 @@ class ModuleDCCAllow : public Module
std::string filename = tokens[2];
if (defaultaction == "allow")
- {
return 0;
- }
for (unsigned int i = 0; i < bfl.size(); i++)
{
if (ServerInstance->MatchText(filename, bfl[i].filemask))
{
- if (strcmp(bfl[i].action.c_str(), "allow") == 0)
- {
+ if (bfl[i].action == "allow")
return 0;
- }
}
else
{
if (defaultaction == "allow")
- {
return 0;
- }
}
user->WriteServ("NOTICE %s :The user %s is not accepting DCC SENDs from you. Your file %s was not sent.", user->nick, u->nick, filename.c_str());
u->WriteServ("NOTICE %s :%s (%s@%s) attempted to send you a file named %s, which was blocked.", u->nick, user->nick, user->ident, user->dhost, filename.c_str());
diff --git a/src/modules/m_restrictbanned.cpp b/src/modules/m_restrictbanned.cpp
index c8c5451ed..b891d5659 100644
--- a/src/modules/m_restrictbanned.cpp
+++ b/src/modules/m_restrictbanned.cpp
@@ -47,7 +47,7 @@ class ModuleRestrictBanned : public Module
if (!IS_LOCAL(user))
return 0;
- if (channel->IsBanned(user) && channel->GetStatus(user) < STATUS_VOICE)
+ if (channel->GetStatus(user) < STATUS_VOICE && channel->IsBanned(user))
{
/* banned, boned. drop the message. */
user->WriteServ("NOTICE "+std::string(user->nick)+" :*** You may not " + action + ", as you are banned on channel " + channel->name);
diff --git a/src/modules/m_services.cpp b/src/modules/m_services.cpp
index 5da01f979..7e6e3121c 100644
--- a/src/modules/m_services.cpp
+++ b/src/modules/m_services.cpp
@@ -230,7 +230,7 @@ class ModuleServices : public Module
chanrec* c = (chanrec*)dest;
if ((c->IsModeSet('M')) && (!user->IsModeSet('r')))
{
- if ((ServerInstance->ULine(user->nick)) || (ServerInstance->ULine(user->server)) || (!strcmp(user->server,"")))
+ if ((ServerInstance->ULine(user->nick)) || (ServerInstance->ULine(user->server)))
{
// user is ulined, can speak regardless
return 0;
diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp
index 9e73ba26b..c13d0e3b3 100644
--- a/src/modules/m_services_account.cpp
+++ b/src/modules/m_services_account.cpp
@@ -159,7 +159,7 @@ class ModuleServicesAccount : public Module
if ((c->IsModeSet('M')) && (!account))
{
- if ((ServerInstance->ULine(user->nick)) || (ServerInstance->ULine(user->server)) || (!strcmp(user->server,"")))
+ if ((ServerInstance->ULine(user->nick)) || (ServerInstance->ULine(user->server)))
{
// user is ulined, can speak regardless
return 0;
diff --git a/src/modules/m_silence_ext.cpp b/src/modules/m_silence_ext.cpp
index 122016dbc..5acd9e22d 100644
--- a/src/modules/m_silence_ext.cpp
+++ b/src/modules/m_silence_ext.cpp
@@ -346,16 +346,8 @@ class ModuleSilence : public Module
{
for (silencelist::const_iterator c = sl->begin(); c != sl->end(); c++)
{
- if ((match(source->GetFullHost(), c->first.c_str())) && ( ((c->second & pattern) > 0)) || ((c->second & SILENCE_ALL) > 0))
- {
- if (((c->second & SILENCE_EXCLUDE) > 0))
- {
- return 0;
- }
- else {
- return 1;
- }
- }
+ if (((((c->second & pattern) > 0)) || ((c->second & SILENCE_ALL) > 0)) && (ServerInstance->MatchText(source->GetFullHost(), c->first)))
+ return !(((c->second & SILENCE_EXCLUDE) > 0));
}
}
return 0;
diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp
index 634358a6c..3254d9895 100644
--- a/src/modules/m_stripcolor.cpp
+++ b/src/modules/m_stripcolor.cpp
@@ -116,14 +116,11 @@ class ModuleStripColor : public Module
DELETE(csc);
}
- // ANSI colour stripping by Doc (Peter Wood)
- virtual void ReplaceLine(std::string &text)
+ // ANSI colour stripping based on C example by Doc (Peter Wood)
+ virtual void ReplaceLine(std::string &sentence)
{
int i, a, len, remove;
- char sentence[MAXBUF];
- strlcpy(sentence,text.c_str(),MAXBUF);
-
- len = text.length();
+ len = sentence.length();
for (i = 0; i < len; i++)
{
@@ -167,8 +164,6 @@ class ModuleStripColor : public Module
i--;
}
}
-
- text = sentence;
}
virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
@@ -180,12 +175,12 @@ class ModuleStripColor : public Module
if (target_type == TYPE_USER)
{
userrec* t = (userrec*)dest;
- active = t->modes['S'-65];
+ active = t->IsModeSet('S');
}
else if (target_type == TYPE_CHANNEL)
{
chanrec* t = (chanrec*)dest;
- active = (t->IsModeSet('S'));
+ active = t->IsModeSet('S');
}
if (active)
{