From 47dda4f61512f6047f2b1dcccd1943aab74726e3 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sat, 10 Jan 2015 15:16:03 +0100 Subject: Reduce std::string::substr() usage substr() returns a new string while erase() and assign() modify the existing one --- src/users.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/users.cpp') diff --git a/src/users.cpp b/src/users.cpp index 9dcbcae0c..34986a183 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -277,7 +277,7 @@ void UserIOHandler::OnDataReady() return; eol_found: // just found a newline. Terminate the string, and pull it out of recvq - recvq = recvq.substr(qpos); + recvq.erase(0, qpos); // TODO should this be moved to when it was inserted in recvq? ServerInstance->stats.Recv += qpos; @@ -764,7 +764,7 @@ void LocalUser::Write(const std::string& text) if (text.length() > ServerInstance->Config->Limits.MaxLine - 2) { // this should happen rarely or never. Crop the string at 512 and try again. - std::string try_again = text.substr(0, ServerInstance->Config->Limits.MaxLine - 2); + std::string try_again(0, ServerInstance->Config->Limits.MaxLine - 2); Write(try_again); return; } -- cgit v1.2.3