Use 'auto' keyword for iterator declarations (part 2)

refs #12561
This commit is contained in:
Gunnar Beutner 2016-08-27 19:56:12 +02:00
parent 602643b93d
commit e8b0797ec4
16 changed files with 26 additions and 29 deletions

View File

@ -45,7 +45,7 @@ void ConfigType::RegisterObject(const ConfigObject::Ptr& object)
{
boost::mutex::scoped_lock lock(m_Mutex);
ObjectMap::iterator it = m_ObjectMap.find(name);
auto it = m_ObjectMap.find(name);
if (it != m_ObjectMap.end()) {
if (it->second == object)

View File

@ -34,8 +34,8 @@ void DependencyGraph::RemoveDependency(Object *parent, Object *child)
{
boost::mutex::scoped_lock lock(m_Mutex);
std::map<Object *, int>& refs = m_Dependencies[child];
std::map<Object *, int>::iterator it = refs.find(parent);
auto& refs = m_Dependencies[child];
auto it = refs.find(parent);
if (it == refs.end())
return;

View File

@ -260,17 +260,15 @@ void Process::IOThreadProc(int tid)
#endif /* _WIN32 */
for (int i = 1; i < count; i++) {
std::map<ProcessHandle, Process::Ptr>::iterator it;
#ifdef _WIN32
it = l_Processes[tid].find(handles[i]);
auto it = l_Processes[tid].find(handles[i]);
#else /* _WIN32 */
std::map<ConsoleHandle, ProcessHandle>::iterator it2;
it2 = l_FDs[tid].find(pfds[i].fd);
auto it2 = l_FDs[tid].find(pfds[i].fd);
if (it2 == l_FDs[tid].end())
continue; /* This should never happen. */
it = l_Processes[tid].find(it2->second);
auto it = l_Processes[tid].find(it2->second);
#endif /* _WIN32 */
if (it == l_Processes[tid].end())

View File

@ -193,7 +193,7 @@ void SocketEventEngineEpoll::ChangeEvents(SocketEvents *se, int events)
{
boost::mutex::scoped_lock lock(m_EventMutex[tid]);
std::map<SOCKET, SocketEventDescriptor>::iterator it = m_Sockets[tid].find(se->m_FD);
auto it = m_Sockets[tid].find(se->m_FD);
if (it == m_Sockets[tid].end())
return;

View File

@ -182,7 +182,7 @@ void SocketEventEnginePoll::ChangeEvents(SocketEvents *se, int events)
{
boost::mutex::scoped_lock lock(m_EventMutex[tid]);
std::map<SOCKET, SocketEventDescriptor>::iterator it = m_Sockets[tid].find(se->m_FD);
auto it = m_Sockets[tid].find(se->m_FD);
if (it == m_Sockets[tid].end())
return;

View File

@ -259,7 +259,7 @@ void Timer::TimerThreadProc(void)
if (l_StopTimerThread)
break;
NextTimerView::iterator it = idx.begin();
auto it = idx.begin();
Timer *timer = *it;
double wait = timer->m_Next - Utility::GetTime();

View File

@ -115,7 +115,7 @@ void CheckerComponent::CheckThreadProc(void)
if (m_Stopped)
break;
CheckTimeView::iterator it = idx.begin();
auto it = idx.begin();
CheckableScheduleInfo csi = *it;
double wait = csi.NextCheck - Utility::GetTime();
@ -227,8 +227,8 @@ void CheckerComponent::ExecuteCheckHelper(const Checkable::Ptr& checkable)
/* remove the object from the list of pending objects; if it's not in the
* list this was a manual (i.e. forced) check and we must not re-add the
* object to the list because it's already there. */
CheckerComponent::CheckableSet::iterator it;
it = m_PendingCheckables.find(checkable);
auto it = m_PendingCheckables.find(checkable);
if (it != m_PendingCheckables.end()) {
m_PendingCheckables.erase(it);
@ -300,7 +300,8 @@ void CheckerComponent::NextCheckChangedHandler(const Checkable::Ptr& checkable)
typedef boost::multi_index::nth_index<CheckableSet, 0>::type CheckableView;
CheckableView& idx = boost::get<0>(m_IdleCheckables);
CheckableView::iterator it = idx.find(checkable);
auto it = idx.find(checkable);
if (it == idx.end())
return;

View File

@ -593,9 +593,9 @@ void TroubleshootCommand::PrintObjectOrigin(InfoLog& log, const std::set<String>
InfoLogLine(log)
<< "The objects origins are:\n";
for (std::set<String>::iterator it = configSet.begin(); it != configSet.end(); it++) {
for (const String& config : configSet) {
InfoLogLine(log)
<< " " << *it << '\n';
<< " " << config << '\n';
}
}

View File

@ -150,7 +150,7 @@ bool ApplyRule::HasMatches(void) const
std::vector<ApplyRule>& ApplyRule::GetRules(const String& type)
{
RuleMap::iterator it = m_Rules.find(type);
auto it = m_Rules.find(type);
if (it == m_Rules.end()) {
static std::vector<ApplyRule> emptyList;
return emptyList;

View File

@ -230,7 +230,7 @@ String Comment::GetCommentIDFromLegacyID(int id)
{
boost::mutex::scoped_lock lock(l_CommentMutex);
std::map<int, String>::iterator it = l_LegacyCommentsCache.find(id);
auto it = l_LegacyCommentsCache.find(id);
if (it == l_LegacyCommentsCache.end())
return Empty;

View File

@ -363,7 +363,7 @@ String Downtime::GetDowntimeIDFromLegacyID(int id)
{
boost::mutex::scoped_lock lock(l_DowntimeMutex);
std::map<int, String>::iterator it = l_LegacyDowntimesCache.find(id);
auto it = l_LegacyDowntimesCache.find(id);
if (it == l_LegacyDowntimesCache.end())
return Empty;

View File

@ -114,8 +114,7 @@ void ExternalCommandProcessor::Execute(double time, const String& command, const
{
boost::mutex::scoped_lock lock(GetMutex());
std::map<String, ExternalCommandInfo>::iterator it;
it = GetCommands().find(command);
auto it = GetCommands().find(command);
if (it == GetCommands().end())
BOOST_THROW_EXCEPTION(std::invalid_argument("The external command '" + command + "' does not exist."));

View File

@ -92,7 +92,7 @@ void Table::AddColumn(const String& name, const Column& column)
{
std::pair<String, Column> item = std::make_pair(name, column);
std::pair<std::map<String, Column>::iterator, bool> ret = m_Columns.insert(item);
auto ret = m_Columns.insert(item);
if (!ret.second)
ret.first->second = column;

View File

@ -182,7 +182,7 @@ void ClrCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
{
boost::mutex::scoped_lock lock(l_ObjectsMutex);
std::map<Checkable::Ptr, variant_t>::iterator it = l_Objects.find(checkable);
auto it = l_Objects.find(checkable);
if (it != l_Objects.end()) {
vtObject = it->second;

View File

@ -61,8 +61,7 @@ void EventQueue::AddClient(void *client)
{
boost::mutex::scoped_lock lock(m_Mutex);
typedef std::map<void *, std::deque<Dictionary::Ptr> >::iterator it_type;
std::pair<it_type, bool> result = m_Events.insert(std::make_pair(client, std::deque<Dictionary::Ptr>()));
auto result = m_Events.insert(std::make_pair(client, std::deque<Dictionary::Ptr>()));
ASSERT(result.second);
}
@ -99,7 +98,7 @@ Dictionary::Ptr EventQueue::WaitForEvent(void *client, double timeout)
boost::mutex::scoped_lock lock(m_Mutex);
for (;;) {
std::map<void *, std::deque<Dictionary::Ptr> >::iterator it = m_Events.find(client);
auto it = m_Events.find(client);
ASSERT(it != m_Events.end());
if (!it->second.empty()) {

View File

@ -208,7 +208,7 @@ void Url::SetQuery(const std::map<String, std::vector<String> >& query)
void Url::AddQueryElement(const String& name, const String& value)
{
std::map<String, std::vector<String> >::iterator it = m_Query.find(name);
auto it = m_Query.find(name);
if (it == m_Query.end()) {
m_Query[name] = std::vector<String>();
m_Query[name].push_back(value);
@ -395,7 +395,7 @@ bool Url::ParseQuery(const String& query)
key = Utility::UnescapeString(key);
std::map<String, std::vector<String> >::iterator it = m_Query.find(key);
auto it = m_Query.find(key);
if (it == m_Query.end()) {
m_Query[key] = std::vector<String>();