Skip to content

Commit 0a416bd

Browse files
committed
Fix compiler warnings by not unnecessarily (copy-)constructing loop variables
1 parent d861a78 commit 0a416bd

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

lib/base/dependencygraph.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ std::vector<Object::Ptr> DependencyGraph::GetParents(const Object::Ptr& child)
4040
auto it = m_Dependencies.find(child.get());
4141

4242
if (it != m_Dependencies.end()) {
43-
typedef std::pair<Object *, int> kv_pair;
44-
for (const kv_pair& kv : it->second) {
43+
typedef std::pair<Object *const, int> kv_pair;
44+
for (kv_pair& kv : it->second) {
4545
objects.emplace_back(kv.first);
4646
}
4747
}

lib/base/process.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,8 @@ void Process::IOThreadProc(int tid)
632632
#endif /* _WIN32 */
633633

634634
int i = 1;
635-
typedef std::pair<ProcessHandle, Process::Ptr> kv_pair;
636-
for (const kv_pair& kv : l_Processes[tid]) {
635+
typedef std::pair<const ProcessHandle, Process::Ptr> kv_pair;
636+
for (kv_pair& kv : l_Processes[tid]) {
637637
const Process::Ptr& process = kv.second;
638638
#ifdef _WIN32
639639
handles[i] = kv.first;

lib/remote/apilistener-configsync.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Value ApiListener::ConfigUpdateObjectAPIHandler(const MessageOrigin::Ptr& origin
125125
<< "Could not create object '" << objName << "':";
126126

127127
ObjectLock olock(errors);
128-
for (const String& error : errors) {
128+
for (auto& error : errors) {
129129
Log(LogCritical, "ApiListener", error);
130130
}
131131

@@ -287,7 +287,7 @@ Value ApiListener::ConfigDeleteObjectAPIHandler(const MessageOrigin::Ptr& origin
287287
Log(LogCritical, "ApiListener", "Could not delete object:");
288288

289289
ObjectLock olock(errors);
290-
for (const String& error : errors) {
290+
for (auto& error : errors) {
291291
Log(LogCritical, "ApiListener", error);
292292
}
293293
}

lib/remote/consolehandler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ static void ScriptFrameCleanupHandler()
3131

3232
std::vector<String> cleanup_keys;
3333

34-
typedef std::pair<String, ApiScriptFrame> KVPair;
34+
typedef std::pair<const String, ApiScriptFrame> KVPair;
3535

36-
for (const KVPair& kv : l_ApiScriptFrames) {
36+
for (KVPair& kv : l_ApiScriptFrames) {
3737
if (kv.second.Seen < Utility::GetTime() - 1800)
3838
cleanup_keys.push_back(kv.first);
3939
}

lib/remote/eventqueue.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ std::vector<EventQueue::Ptr> EventQueue::GetQueuesForType(const String& type)
116116

117117
std::vector<EventQueue::Ptr> availQueues;
118118

119-
typedef std::pair<String, EventQueue::Ptr> kv_pair;
120-
for (const kv_pair& kv : queues) {
119+
typedef std::pair<const String, EventQueue::Ptr> kv_pair;
120+
for (kv_pair& kv : queues) {
121121
if (kv.second->CanProcessEvent(type))
122122
availQueues.push_back(kv.second);
123123
}

tools/mkclass/classcompiler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
905905
if (field.Type.ArrayRank > 0) {
906906
m_Impl << "\t" << "if (oldValue) {" << std::endl
907907
<< "\t\t" << "ObjectLock olock(oldValue);" << std::endl
908-
<< "\t\t" << "for (const String& ref : oldValue) {" << std::endl
908+
<< "\t\t" << "for (auto& ref : oldValue) {" << std::endl
909909
<< "\t\t\t" << "DependencyGraph::RemoveDependency(this, ConfigObject::GetObject";
910910

911911
/* Ew */
@@ -919,7 +919,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
919919
<< "\t" << "}" << std::endl
920920
<< "\t" << "if (newValue) {" << std::endl
921921
<< "\t\t" << "ObjectLock olock(newValue);" << std::endl
922-
<< "\t\t" << "for (const String& ref : newValue) {" << std::endl
922+
<< "\t\t" << "for (auto& ref : newValue) {" << std::endl
923923
<< "\t\t\t" << "DependencyGraph::AddDependency(this, ConfigObject::GetObject";
924924

925925
/* Ew */

0 commit comments

Comments
 (0)