From: brain Date: Thu, 17 Aug 2006 14:12:10 +0000 (+0000) Subject: Improve userrec::AddBuffer (remove craq char to std::string loop) X-Git-Tag: v2.0.23~7378 X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=7a76705c4c2014eb8470d81fd30f416518010cbe;p=user%2Fhenk%2Fcode%2Finspircd.git Improve userrec::AddBuffer (remove craq char to std::string loop) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4932 e03df62e-2008-0410-955e-edbf42e46eb7 --- diff --git a/src/users.cpp b/src/users.cpp index 43d09554d..aab40aa1d 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -480,15 +480,13 @@ bool userrec::HasPermission(const std::string &command) bool userrec::AddBuffer(const std::string &a) { - std::string b = ""; + std::string b(a); + std::string::size_type i = b.rfind('\r'); - /* NB: std::string is arsey about \r and \n and tries to translate them - * somehow, so we CANNOT use std::string::find() here :( - */ - for (std::string::const_iterator i = a.begin(); i != a.end(); i++) + while (i != std::string::npos) { - if (*i != '\r') - b += *i; + b.erase(i, 1); + i = b.rfind('\r'); } if (b.length())