From 7a76705c4c2014eb8470d81fd30f416518010cbe Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 17 Aug 2006 14:12:10 +0000 Subject: 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 --- src/users.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src') 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()) -- cgit v1.2.3