summaryrefslogtreecommitdiff
path: root/src/modules/m_spanningtree
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2015-01-10 15:16:03 +0100
committerAttila Molnar <attilamolnar@hush.com>2015-01-10 15:16:03 +0100
commit47dda4f61512f6047f2b1dcccd1943aab74726e3 (patch)
treea1425a9dbff58b97ef5dcdf169e0d65439513527 /src/modules/m_spanningtree
parentae10286658d6bb70e5e22526a004ec1b233f6fba (diff)
Reduce std::string::substr() usage
substr() returns a new string while erase() and assign() modify the existing one
Diffstat (limited to 'src/modules/m_spanningtree')
-rw-r--r--src/modules/m_spanningtree/capab.cpp4
-rw-r--r--src/modules/m_spanningtree/compat.cpp4
-rw-r--r--src/modules/m_spanningtree/postcommand.cpp2
-rw-r--r--src/modules/m_spanningtree/server.cpp2
-rw-r--r--src/modules/m_spanningtree/treesocket1.cpp2
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp2
6 files changed, 8 insertions, 8 deletions
diff --git a/src/modules/m_spanningtree/capab.cpp b/src/modules/m_spanningtree/capab.cpp
index f27fe8889..047808c29 100644
--- a/src/modules/m_spanningtree/capab.cpp
+++ b/src/modules/m_spanningtree/capab.cpp
@@ -386,8 +386,8 @@ bool TreeSocket::Capab(const parameterlist &params)
std::string::size_type equals = item.find('=');
if (equals != std::string::npos)
{
- std::string var = item.substr(0, equals);
- std::string value = item.substr(equals+1, item.length());
+ std::string var(item, 0, equals);
+ std::string value(item, equals+1);
capab->CapKeys[var] = value;
}
}
diff --git a/src/modules/m_spanningtree/compat.cpp b/src/modules/m_spanningtree/compat.cpp
index 127907836..c2ee940fc 100644
--- a/src/modules/m_spanningtree/compat.cpp
+++ b/src/modules/m_spanningtree/compat.cpp
@@ -46,7 +46,7 @@ void TreeSocket::WriteLine(const std::string& original_line)
std::string line = original_line;
std::string::size_type a = line.find(' ');
std::string::size_type b = line.find(' ', a + 1);
- std::string command = line.substr(a + 1, b-a-1);
+ std::string command(line, a + 1, b-a-1);
// now try to find a translation entry
// TODO a more efficient lookup method will be needed later
if (proto_version < 1205)
@@ -68,7 +68,7 @@ void TreeSocket::WriteLine(const std::string& original_line)
{
// No TS or modes in the command
// :22DAAAAAB IJOIN #chan
- const std::string channame = line.substr(b+1, c-b-1);
+ const std::string channame(line, b+1, c-b-1);
Channel* chan = ServerInstance->FindChan(channame);
if (!chan)
return;
diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp
index 0695ce632..ae98be946 100644
--- a/src/modules/m_spanningtree/postcommand.cpp
+++ b/src/modules/m_spanningtree/postcommand.cpp
@@ -89,7 +89,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm
if (ServerInstance->Modes->FindPrefix(dest[0]))
{
pfx = dest[0];
- dest = dest.substr(1);
+ dest.erase(dest.begin());
}
if (dest[0] == '#')
{
diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp
index d7c6332f2..1c624f5c4 100644
--- a/src/modules/m_spanningtree/server.cpp
+++ b/src/modules/m_spanningtree/server.cpp
@@ -81,7 +81,7 @@ void CommandServer::HandleExtra(TreeServer* newserver, const std::vector<std::st
if (p != std::string::npos)
{
key.erase(p);
- val = prop.substr(p+1);
+ val.assign(prop, p+1, std::string::npos);
}
if (key == "burst")
diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp
index 1a8bdd06c..d2fec0118 100644
--- a/src/modules/m_spanningtree/treesocket1.cpp
+++ b/src/modules/m_spanningtree/treesocket1.cpp
@@ -177,7 +177,7 @@ void TreeSocket::OnDataReady()
{
std::string::size_type rline = line.find('\r');
if (rline != std::string::npos)
- line = line.substr(0,rline);
+ line.erase(rline);
if (line.find('\0') != std::string::npos)
{
SendError("Read null character from socket");
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index 25b8e3b71..1f98f7819 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -47,7 +47,7 @@ void TreeSocket::Split(const std::string& line, std::string& prefix, std::string
if (prefix[0] == ':')
{
- prefix = prefix.substr(1);
+ prefix.erase(prefix.begin());
if (prefix.empty())
{