]> git.tdb.fi Git - libs/net.git/commitdiff
Use the auto type to shorten long declarations
authorMikko Rasa <tdb@tdb.fi>
Fri, 9 Dec 2022 22:22:01 +0000 (00:22 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 9 Dec 2022 22:22:01 +0000 (00:22 +0200)
source/http/formdata.cpp
source/http/header.cpp
source/http/message.cpp
source/http/server.cpp
source/net/resolve.cpp

index 9897bc59b4a1a663ba8d5f124909582e9b75e131..4ec3f8867f8039399255283205f6fae231fba585 100644 (file)
@@ -83,7 +83,7 @@ void FormData::parse_multipart(const Request &req, const string &boundary)
 
 const string &FormData::get_value(const string &key) const
 {
-       map<string, string>::const_iterator i = fields.find(key);
+       auto i = fields.find(key);
        if(i==fields.end())
        {
                static string dummy;
index 3027d17d887eddaba34ff03fc90ade533c4b55cd..b55223e8d51cf082ad2db22fa08ed46b93b16492 100644 (file)
@@ -53,12 +53,12 @@ void Header::parse()
 
        char value_sep = (style==VALUE_WITH_ATTRIBUTES ? 0 : ',');
 
-       string::const_iterator i = raw_value.begin();
-       while(i!=raw_value.end())
+       auto i = raw_value.cbegin();
+       while(i!=raw_value.cend())
        {
                Value value;
 
-               string::const_iterator start = i;
+               auto start = i;
                if(style==KEY_VALUE_LIST)
                        value.value = name;
                else
index 2ae0ff80a641e3f133f051c37fe66569e6a93944..99d149725c80db88f5c534547369da8ddac90401 100644 (file)
@@ -48,7 +48,7 @@ unsigned Message::parse_content(const string &d)
        if(complete)
                return 0;
 
-       HeaderMap::const_iterator i = headers.find("Content-Length");
+       auto i = headers.find("Content-Length");
        if(i!=headers.end())
        {
                string::size_type needed = lexical_cast<string::size_type>(i->second)-content.size();
index 6055f008e4ff13328a6bf5409584a7e96f682458..c52bec4e7e89a2b3a703a657eecc88b102407788 100644 (file)
@@ -95,7 +95,7 @@ void Server::close_connections(const Time::TimeDelta &timeout)
        while(!clients.empty() && poller.poll(timeout))
        {
                for(const IO::Poller::PolledObject &p: poller.get_result())
-                       for(list<Client>::iterator j=clients.begin(); j!=clients.end(); ++j)
+                       for(auto j=clients.begin(); j!=clients.end(); ++j)
                                if(j->sock.get()==p.object)
                                {
                                        poller.set_object(*j->sock, IO::P_NONE);
@@ -117,7 +117,7 @@ void Server::data_available()
 
 void Server::client_data_available(Client &cl)
 {
-       for(list<Client>::iterator i=clients.begin(); i!=clients.end(); ++i)
+       for(auto i=clients.begin(); i!=clients.end(); ++i)
                if(i->stale && &*i!=&cl)
                {
                        clients.erase(i);
index cd65b9caccc66b6fb0a88f813850ea387d9ffaac..c30d62a7bd9f471f1d621477d5f3536fc39e4adf 100644 (file)
@@ -211,7 +211,7 @@ void Resolver::WorkerThread::main()
                Task *task = 0;
                {
                        MutexLock lock(queue_mutex);
-                       for(deque<Task>::iterator i=queue.begin(); (!task && i!=queue.end()); ++i)
+                       for(auto i=queue.begin(); (!task && i!=queue.end()); ++i)
                                if(!i->is_complete())
                                        task = &*i;
                }