]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
*Changed user input/output buffering to incur less copies
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 16 Jul 2006 15:45:13 +0000 (15:45 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 16 Jul 2006 15:45:13 +0000 (15:45 +0000)
*Fix warnings in command_parse

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4418 e03df62e-2008-0410-955e-edbf42e46eb7

src/command_parse.cpp
src/users.cpp

index 7d930ec65640f0578f051d0d94ccf552f8b8fdae..b483c410bbe46b4bf4087fc116e17825bb97ccb9 100644 (file)
@@ -104,7 +104,7 @@ int CommandParser::LoopCall(userrec* user, command_t* CommandObj, const char** p
        irc::commasepstream items1(parameters[splithere]);
        irc::commasepstream items2(parameters[extra]);
        std::string item = "";
-       int max = 0;
+       unsigned int max = 0;
 
        /* Attempt to iterate these lists and call the command objech
         * which called us, for every parameter pair until there are
@@ -131,7 +131,7 @@ int CommandParser::LoopCall(userrec* user, command_t* CommandObj, const char** p
        /* Only one commasepstream here */
        irc::commasepstream items1(parameters[splithere]);
        std::string item = "";
-       int max = 0;
+       unsigned int max = 0;
 
        /* Parse the commasepstream until there are no tokens remaining.
         * Each token we parse out, call the command handler that called us
index 61a5be70a613c5bae76b8ad90c61fb0e7393ca66..10a0a0353682e3ddaaaa444de0875fd1c1798ee9 100644 (file)
@@ -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;