From 9e743c99fb69db5694c388ae33656c62e3fa0b8e Mon Sep 17 00:00:00 2001 From: Fawrsk Date: Sat, 7 Jan 2023 00:38:12 -0400 Subject: Cleanup for loops in llcommon to use C++11 range based for loops --- indra/llcommon/llcallstack.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'indra/llcommon/llcallstack.cpp') diff --git a/indra/llcommon/llcallstack.cpp b/indra/llcommon/llcallstack.cpp index 8db291eed1..fac03e0c9e 100644 --- a/indra/llcommon/llcallstack.cpp +++ b/indra/llcommon/llcallstack.cpp @@ -91,10 +91,9 @@ LLCallStack::LLCallStack(S32 skip_count, bool verbose): bool LLCallStack::contains(const std::string& str) { - for (std::vector::const_iterator it = m_strings.begin(); - it != m_strings.end(); ++it) + for (const std::string& src_str : m_strings) { - if (it->find(str) != std::string::npos) + if (src_str.find(str) != std::string::npos) { return true; } @@ -105,10 +104,9 @@ bool LLCallStack::contains(const std::string& str) std::ostream& operator<<(std::ostream& s, const LLCallStack& call_stack) { #ifndef LL_RELEASE_FOR_DOWNLOAD - std::vector::const_iterator it; - for (it=call_stack.m_strings.begin(); it!=call_stack.m_strings.end(); ++it) + for (const std::string& str : call_stack.m_strings) { - s << *it; + s << str; } #else s << "UNAVAILABLE IN RELEASE"; @@ -156,9 +154,9 @@ bool LLContextStrings::contains(const std::string& str) { const std::map& strings = LLThreadLocalSingletonPointer::getInstance()->m_contextStrings; - for (std::map::const_iterator it = strings.begin(); it!=strings.end(); ++it) + for (const std::map::value_type str_pair : strings) { - if (it->first.find(str) != std::string::npos) + if (str_pair.first.find(str) != std::string::npos) { return true; } @@ -171,9 +169,9 @@ void LLContextStrings::output(std::ostream& os) { const std::map& strings = LLThreadLocalSingletonPointer::getInstance()->m_contextStrings; - for (std::map::const_iterator it = strings.begin(); it!=strings.end(); ++it) + for (const std::map::value_type str_pair : strings) { - os << it->first << "[" << it->second << "]" << "\n"; + os << str_pair.first << "[" << str_pair.second << "]" << "\n"; } } -- cgit v1.2.3 From 8767e6995b0c9b9ed23e07f63d290a1da8c70f17 Mon Sep 17 00:00:00 2001 From: Fawrsk Date: Mon, 9 Jan 2023 19:19:12 -0400 Subject: Eliminate needless copies --- indra/llcommon/llcallstack.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/llcallstack.cpp') diff --git a/indra/llcommon/llcallstack.cpp b/indra/llcommon/llcallstack.cpp index fac03e0c9e..83d5ae2a63 100644 --- a/indra/llcommon/llcallstack.cpp +++ b/indra/llcommon/llcallstack.cpp @@ -154,7 +154,7 @@ bool LLContextStrings::contains(const std::string& str) { const std::map& strings = LLThreadLocalSingletonPointer::getInstance()->m_contextStrings; - for (const std::map::value_type str_pair : strings) + for (const std::map::value_type& str_pair : strings) { if (str_pair.first.find(str) != std::string::npos) { @@ -169,7 +169,7 @@ void LLContextStrings::output(std::ostream& os) { const std::map& strings = LLThreadLocalSingletonPointer::getInstance()->m_contextStrings; - for (const std::map::value_type str_pair : strings) + for (const std::map::value_type& str_pair : strings) { os << str_pair.first << "[" << str_pair.second << "]" << "\n"; } -- cgit v1.2.3