summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-17 14:16:15 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-17 14:16:15 +0000
commit4bf95512bc85eb8bdcbf48a00a52a23bf50b296b (patch)
tree68fcb563eb58e2eb25ccb8917c5d1f591a4c96c9
parent7a76705c4c2014eb8470d81fd30f416518010cbe (diff)
userrec::AddBuffer and userrec::Write end up copying the const std::string& into a non-const to make use of it, why not just pass std::string and let the compiler do the copy when passing it?
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4933 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/users.h4
-rw-r--r--src/users.cpp22
2 files changed, 12 insertions, 14 deletions
diff --git a/include/users.h b/include/users.h
index 9b3292caf..b292cd998 100644
--- a/include/users.h
+++ b/include/users.h
@@ -447,7 +447,7 @@ class userrec : public connection
* @param a The string to add to the users read buffer
* @return True if the string was successfully added to the read buffer
*/
- bool AddBuffer(const std::string &a);
+ bool AddBuffer(std::string a);
/** This method returns true if the buffer contains at least one carriage return
* character (e.g. one complete line may be read)
@@ -596,7 +596,7 @@ class userrec : public connection
/** Write text to this user, appending CR/LF.
* @param text A std::string to send to the user
*/
- void Write(const std::string &text);
+ void Write(std::string text);
/** Write text to this user, appending CR/LF.
* @param text The format string for text to send to the user
diff --git a/src/users.cpp b/src/users.cpp
index aab40aa1d..9d7e8dc28 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -478,19 +478,18 @@ bool userrec::HasPermission(const std::string &command)
}
-bool userrec::AddBuffer(const std::string &a)
+bool userrec::AddBuffer(std::string a)
{
- std::string b(a);
- std::string::size_type i = b.rfind('\r');
+ std::string::size_type i = a.rfind('\r');
while (i != std::string::npos)
{
b.erase(i, 1);
- i = b.rfind('\r');
+ i = a.rfind('\r');
}
- if (b.length())
- recvq.append(b);
+ if (a.length())
+ recvq.append(a);
if (recvq.length() > (unsigned)this->recvqmax)
{
@@ -1271,19 +1270,18 @@ const char* userrec::GetIPString(char* buf)
}
-void userrec::Write(const std::string &text)
+void userrec::Write(std::string text)
{
if ((this->fd < 0) || (this->fd > MAX_DESCRIPTORS))
return;
- std::string crlf = text;
- crlf.append("\r\n");
+ text.append("\r\n");
if (ServerInstance->Config->GetIOHook(this->GetPort()))
{
try
{
- ServerInstance->Config->GetIOHook(this->GetPort())->OnRawSocketWrite(this->fd, crlf.data(), crlf.length());
+ ServerInstance->Config->GetIOHook(this->GetPort())->OnRawSocketWrite(this->fd, text.data(), text.length());
}
catch (ModuleException& modexcept)
{
@@ -1292,9 +1290,9 @@ void userrec::Write(const std::string &text)
}
else
{
- this->AddWriteBuf(crlf);
+ this->AddWriteBuf(text);
}
- ServerInstance->stats->statsSent += crlf.length();
+ ServerInstance->stats->statsSent += text.length();
}
/** Write()