summaryrefslogtreecommitdiff
path: root/src/users.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-16 15:45:13 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-16 15:45:13 +0000
commitf8956e4b455e27e0c694b0651cad090752d3a83f (patch)
tree608dacf37a982a4a3f1468aad0affea74af3ff43 /src/users.cpp
parentb07953b0e7da6291914bf417d7290e3ab2a913db (diff)
*Changed user input/output buffering to incur less copies
*Fix warnings in command_parse git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4418 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/users.cpp')
-rw-r--r--src/users.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/users.cpp b/src/users.cpp
index 61a5be70a..10a0a0353 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -397,9 +397,8 @@ bool userrec::HasPermission(const std::string &command)
bool userrec::AddBuffer(const std::string &a)
{
std::string b = "";
- char* n = (char*)a.c_str();
- for (char* i = n; *i; i++)
+ for (std::string::const_iterator i = a.begin(); i != a.end(); i++)
{
if ((*i != '\r') && (*i != '\0') && (*i != 7))
b = b + *i;
@@ -429,12 +428,7 @@ bool userrec::AddBuffer(const std::string &a)
bool userrec::BufferIsReady()
{
- unsigned int t = recvq.length();
-
- for (unsigned int i = 0; i < t; i++)
- if (recvq[i] == '\n')
- return true;
- return false;
+ return (recvq.find('\n') != std::string::npos);
}
void userrec::ClearBuffer()
@@ -447,10 +441,10 @@ std::string userrec::GetBuffer()
if (recvq == "")
return "";
- char* line = (char*)recvq.c_str();
+ const char* line = recvq.c_str();
std::string ret = "";
-
+
while ((*line != '\n') && (*line))
{
ret = ret + *line;