diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-07-01 12:06:15 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-07-01 12:06:15 +0000 |
commit | 8199f4dd3e64450d464c0ac97b34d90c165df066 (patch) | |
tree | 21c060d81d8ea6c76ba215a9b40845c65722d741 | |
parent | 9ec0ed03e69d3b31176f71fa1b7b68bca5b5c9f0 (diff) |
Optimizations and code tidyups. QA please check that svsnick and other forced nick changes still work right after this
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7416 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/cmd_ison.cpp | 2 | ||||
-rw-r--r-- | src/cmd_stats.cpp | 2 | ||||
-rw-r--r-- | src/command_parse.cpp | 4 | ||||
-rw-r--r-- | src/dns.cpp | 2 | ||||
-rw-r--r-- | src/mode.cpp | 4 | ||||
-rw-r--r-- | src/userprocess.cpp | 5 | ||||
-rw-r--r-- | src/users.cpp | 12 | ||||
-rw-r--r-- | src/xline.cpp | 4 |
8 files changed, 17 insertions, 18 deletions
diff --git a/src/cmd_ison.cpp b/src/cmd_ison.cpp index c76bf40e1..0cee160c7 100644 --- a/src/cmd_ison.cpp +++ b/src/cmd_ison.cpp @@ -51,7 +51,7 @@ CmdResult cmd_ison::Handle (const char** parameters, int pcnt, userrec *user) /* Its a space seperated list of nicks (RFC1459 says to support this) */ irc::spacesepstream list(parameters[i]); - std::string item = "*"; + std::string item("*"); while (((item = list.GetToken()) != "")) { u = ServerInstance->FindNick(item); diff --git a/src/cmd_stats.cpp b/src/cmd_stats.cpp index 037ffe304..98b2c63dd 100644 --- a/src/cmd_stats.cpp +++ b/src/cmd_stats.cpp @@ -71,7 +71,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, userrec* user, { std::string ip = ServerInstance->Config->ports[i]->GetIP(); if (ip.empty()) - ip = "*"; + ip.assign("*"); results.push_back(sn+" 249 "+user->nick+" :"+ ip + ":"+ConvToStr(ServerInstance->Config->ports[i]->GetPort())+" (client, " + ServerInstance->Config->ports[i]->GetDescription() + ")"); diff --git a/src/command_parse.cpp b/src/command_parse.cpp index d03cb9296..ba06c96e1 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -133,7 +133,7 @@ int CommandParser::LoopCall(userrec* user, command_t* CommandObj, const char** p */ irc::commasepstream items1(parameters[splithere]); irc::commasepstream items2(parameters[extra]); - std::string item = "*"; + std::string item("*"); unsigned int max = 0; /* Attempt to iterate these lists and call the command objech @@ -174,7 +174,7 @@ int CommandParser::LoopCall(userrec* user, command_t* CommandObj, const char** p /* Only one commasepstream here */ irc::commasepstream items1(parameters[splithere]); - std::string item = "*"; + std::string item("*"); unsigned int max = 0; /* Parse the commasepstream until there are no tokens remaining. diff --git a/src/dns.cpp b/src/dns.cpp index c3e909700..fab9631b7 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -756,7 +756,7 @@ DNSResult DNS::GetResult() * as the last parameter on the line with a value ":1". */ if (*formatted == ':') - resultstr = "0" + resultstr; + resultstr.insert(0, "0"); } break; diff --git a/src/mode.cpp b/src/mode.cpp index 14dd39b33..ebf18b1cf 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -483,8 +483,8 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool parameter = parameters[parameter_counter++]; /* Yerk, invalid! */ - if ((parameter.find(':') == 0) || (parameter.rfind(' ') != std::string::npos)) - parameter = ""; + if ((parameter.find(':', 0, 1) == 0) || (parameter.rfind(' ') != std::string::npos)) + parameter.clear(); } else { diff --git a/src/userprocess.cpp b/src/userprocess.cpp index e79c879c2..36523e522 100644 --- a/src/userprocess.cpp +++ b/src/userprocess.cpp @@ -274,9 +274,10 @@ void InspIRCd::DoBackgroundUserStuff(time_t TIME) { /* Everybody loves boobies. */ time_t time = this->Time(false) - (curr->nping - curr->pingmax); - std::string boobies = "Ping timeout: " + ConvToStr(time) + " second" + (time > 1 ? "s" : ""); + char message[MAXBUF]; + snprintf(message, MAXBUF, "Ping timeout: %d second%s", time, time > 1 ? "s" : ""); curr->muted = true; - GlobalCulls.AddItem(curr, boobies); + GlobalCulls.AddItem(curr, message); curr->lastping = 1; curr->nping = TIME+curr->pingmax; continue; diff --git a/src/users.cpp b/src/users.cpp index 5bfc9a46b..bc221b263 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -198,7 +198,7 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl, else if ((this->fwd) && (ServerInstance->SE->GetRef(this->bound_fd) == this->bound_user)) { /* Both lookups completed */ - std::string result2 = "0::ffff:"; + std::string result2("0::ffff:"); result2.append(result); if (this->bound_user->GetIPString() == result || this->bound_user->GetIPString() == result2) { @@ -210,7 +210,7 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl, { /* Hostnames starting with : are not a good thing (tm) */ if (*(hostname.c_str()) == ':') - hostname = "0" + hostname; + hostname.insert(0, "0"); this->bound_user->WriteServ("NOTICE Auth :*** Found your hostname (%s)%s", hostname.c_str(), (cached ? " -- cached" : "")); this->bound_user->dns_done = true; @@ -1181,10 +1181,7 @@ bool userrec::ForceNickChange(const char* newnick) if (this->registered == REG_ALL) { - const char* pars[1]; - pars[0] = newnick; - std::string cmd = "NICK"; - return (ServerInstance->Parser->CallHandler(cmd, pars, 1, this) == CMD_SUCCESS); + return (ServerInstance->Parser->CallHandler("NICK", &newnick, 1, this) == CMD_SUCCESS); } return false; } @@ -1620,7 +1617,8 @@ void userrec::WriteWallOps(const std::string &text) if (!IS_OPER(this) && IS_LOCAL(this)) return; - std::string wallop = "WALLOPS :" + text; + std::string wallop("WALLOPS :"); + wallop.append(text); for (std::vector<userrec*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++) { diff --git a/src/xline.cpp b/src/xline.cpp index 9b05a57f8..def9db42b 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -109,9 +109,9 @@ IdentHostPair XLineManager::IdentSplit(const std::string &ident_and_host) n.second = ident_and_host.substr(x + 1,ident_and_host.length()); n.first = ident_and_host.substr(0, x); if (!n.first.length()) - n.first = "*"; + n.first.assign("*"); if (!n.second.length()) - n.second = "*"; + n.second.assign("*"); } else { |