From: Mikko Rasa Date: Fri, 9 Dec 2022 22:22:01 +0000 (+0200) Subject: Use the auto type to shorten long declarations X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=dd1884f1aaef4df246d78cabc9d937e5ebc3e511;p=libs%2Fnet.git Use the auto type to shorten long declarations --- diff --git a/source/http/formdata.cpp b/source/http/formdata.cpp index 9897bc5..4ec3f88 100644 --- a/source/http/formdata.cpp +++ b/source/http/formdata.cpp @@ -83,7 +83,7 @@ void FormData::parse_multipart(const Request &req, const string &boundary) const string &FormData::get_value(const string &key) const { - map::const_iterator i = fields.find(key); + auto i = fields.find(key); if(i==fields.end()) { static string dummy; diff --git a/source/http/header.cpp b/source/http/header.cpp index 3027d17..b55223e 100644 --- a/source/http/header.cpp +++ b/source/http/header.cpp @@ -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 diff --git a/source/http/message.cpp b/source/http/message.cpp index 2ae0ff8..99d1497 100644 --- a/source/http/message.cpp +++ b/source/http/message.cpp @@ -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(i->second)-content.size(); diff --git a/source/http/server.cpp b/source/http/server.cpp index 6055f00..c52bec4 100644 --- a/source/http/server.cpp +++ b/source/http/server.cpp @@ -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::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::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); diff --git a/source/net/resolve.cpp b/source/net/resolve.cpp index cd65b9c..c30d62a 100644 --- a/source/net/resolve.cpp +++ b/source/net/resolve.cpp @@ -211,7 +211,7 @@ void Resolver::WorkerThread::main() Task *task = 0; { MutexLock lock(queue_mutex); - for(deque::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; }