Skip to content

Commit

Permalink
Use 'auto' keyword for iterator declarations (part 2)
Browse files Browse the repository at this point in the history
refs #12561
  • Loading branch information
gunnarbeutner committed Aug 27, 2016
1 parent 602643b commit e8b0797
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 29 deletions.
2 changes: 1 addition & 1 deletion lib/base/configtype.cpp
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/base/dependencygraph.cpp
Expand Up @@ -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;
Expand Down
8 changes: 3 additions & 5 deletions lib/base/process.cpp
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion lib/base/socketevents-epoll.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/base/socketevents-poll.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/base/timer.cpp
Expand Up @@ -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();
Expand Down
9 changes: 5 additions & 4 deletions lib/checker/checkercomponent.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions lib/cli/troubleshootcommand.cpp
Expand Up @@ -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';
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/config/applyrule.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/icinga/comment.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/icinga/downtime.cpp
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions lib/icinga/externalcommandprocessor.cpp
Expand Up @@ -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."));
Expand Down
2 changes: 1 addition & 1 deletion lib/livestatus/table.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/methods/clrchecktask.cpp
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions lib/remote/eventqueue.cpp
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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()) {
Expand Down
4 changes: 2 additions & 2 deletions lib/remote/url.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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>();
Expand Down

0 comments on commit e8b0797

Please sign in to comment.