From d0f115ae093e8268da2a3245d6cb2f3bcc544f1c Mon Sep 17 00:00:00 2001 From: Fawrsk Date: Thu, 5 Jan 2023 07:42:27 -0400 Subject: SL-18893 Cleanup for loops in llcharacter to use C++11 range based for loops (#42) --- indra/llcharacter/lljoint.cpp | 56 ++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 35 deletions(-) (limited to 'indra/llcharacter/lljoint.cpp') diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index d72282ab42..282db5c88b 100644 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -67,11 +67,10 @@ void LLVector3OverrideMap::showJointVector3Overrides( std::ostringstream& os ) c map_type::const_iterator max_it = std::max_element(m_map.begin(), m_map.end(), attachment_map_iter_compare_key); - for (map_type::const_iterator it = m_map.begin(); - it != m_map.end(); ++it) + for (const map_type::value_type pos_pair : m_map) { - const LLVector3& pos = it->second; - os << " " << "[" << it->first <<": " << pos << "]" << ((it==max_it) ? "*" : ""); + const LLVector3& pos = pos_pair.second; + os << " " << "[" << pos_pair.first <<": " << pos << "]" << ((pos_pair==(*max_it)) ? "*" : ""); } } @@ -209,10 +208,8 @@ void LLJoint::touch(U32 flags) child_flags |= POSITION_DIRTY; } - for (joints_t::iterator iter = mChildren.begin(); - iter != mChildren.end(); ++iter) + for (LLJoint* joint : mChildren) { - LLJoint* joint = *iter; joint->touch(child_flags); } } @@ -251,10 +248,8 @@ LLJoint *LLJoint::findJoint( const std::string &name ) if (name == getName()) return this; - for (joints_t::iterator iter = mChildren.begin(); - iter != mChildren.end(); ++iter) + for (LLJoint* joint : mChildren) { - LLJoint* joint = *iter; LLJoint *found = joint->findJoint(name); if (found) { @@ -514,10 +509,9 @@ void LLJoint::getAllAttachmentPosOverrides(S32& num_pos_overrides, std::set& distinct_pos_overrides) const { num_pos_overrides = m_attachmentPosOverrides.count(); - LLVector3OverrideMap::map_type::const_iterator it = m_attachmentPosOverrides.getMap().begin(); - for (; it != m_attachmentPosOverrides.getMap().end(); ++it) + for (LLVector3OverrideMap::map_type::value_type pos_override_pair : m_attachmentPosOverrides.getMap()) { - distinct_pos_overrides.insert(it->second); + distinct_pos_overrides.insert(pos_override_pair.second); } } @@ -528,10 +522,9 @@ void LLJoint::getAllAttachmentScaleOverrides(S32& num_scale_overrides, std::set& distinct_scale_overrides) const { num_scale_overrides = m_attachmentScaleOverrides.count(); - LLVector3OverrideMap::map_type::const_iterator it = m_attachmentScaleOverrides.getMap().begin(); - for (; it != m_attachmentScaleOverrides.getMap().end(); ++it) + for (LLVector3OverrideMap::map_type::value_type scale_override_pair : m_attachmentScaleOverrides.getMap()) { - distinct_scale_overrides.insert(it->second); + distinct_scale_overrides.insert(scale_override_pair.second); } } @@ -556,10 +549,9 @@ void LLJoint::showAttachmentPosOverrides(const std::string& av_info) const { LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " has " << count << " attachment pos overrides" << LL_ENDL; std::set distinct_offsets; - LLVector3OverrideMap::map_type::const_iterator it = m_attachmentPosOverrides.getMap().begin(); - for (; it != m_attachmentPosOverrides.getMap().end(); ++it) + for (LLVector3OverrideMap::map_type::value_type pos_override_pair : m_attachmentPosOverrides.getMap()) { - distinct_offsets.insert(it->second); + distinct_offsets.insert(pos_override_pair.second); } if (distinct_offsets.size()>1) { @@ -569,11 +561,10 @@ void LLJoint::showAttachmentPosOverrides(const std::string& av_info) const { LL_DEBUGS("Avatar") << "no conflicts" << LL_ENDL; } - std::set::iterator dit = distinct_offsets.begin(); - for ( ; dit != distinct_offsets.end(); ++dit) + for (const LLVector3& offset : distinct_offsets) { - std::string highlight = (has_active_override && *dit == active_override) ? "*" : ""; - LL_DEBUGS("Avatar") << " POS " << highlight << "" << (*dit) << " default " << mDefaultPosition << LL_ENDL; + std::string highlight = (has_active_override && offset == active_override) ? "*" : ""; + LL_DEBUGS("Avatar") << " POS " << highlight << "" << offset << " default " << mDefaultPosition << LL_ENDL; } } } @@ -717,10 +708,9 @@ void LLJoint::showAttachmentScaleOverrides(const std::string& av_info) const { LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " has " << count << " attachment scale overrides" << LL_ENDL; std::set distinct_offsets; - LLVector3OverrideMap::map_type::const_iterator it = m_attachmentScaleOverrides.getMap().begin(); - for (; it != m_attachmentScaleOverrides.getMap().end(); ++it) + for (LLVector3OverrideMap::map_type::value_type scale_override_pair : m_attachmentScaleOverrides.getMap()) { - distinct_offsets.insert(it->second); + distinct_offsets.insert(scale_override_pair.second); } if (distinct_offsets.size()>1) { @@ -731,10 +721,10 @@ void LLJoint::showAttachmentScaleOverrides(const std::string& av_info) const LL_DEBUGS("Avatar") << "no conflicts" << LL_ENDL; } std::set::iterator dit = distinct_offsets.begin(); - for ( ; dit != distinct_offsets.end(); ++dit) + for (const LLVector3& offset : distinct_offsets) { - std::string highlight = (has_active_override && *dit == active_override) ? "*" : ""; - LL_DEBUGS("Avatar") << " POS " << highlight << "" << (*dit) << " default " << mDefaultScale << LL_ENDL; + std::string highlight = (has_active_override && offset == active_override) ? "*" : ""; + LL_DEBUGS("Avatar") << " POS " << highlight << "" << offset << " default " << mDefaultScale << LL_ENDL; } } } @@ -993,10 +983,8 @@ void LLJoint::updateWorldMatrixChildren() { updateWorldMatrix(); } - for (joints_t::iterator iter = mChildren.begin(); - iter != mChildren.end(); ++iter) + for (LLJoint* joint : mChildren) { - LLJoint* joint = *iter; joint->updateWorldMatrixChildren(); } } @@ -1040,10 +1028,8 @@ void LLJoint::clampRotation(LLQuaternion old_rot, LLQuaternion new_rot) { LLVector3 main_axis(1.f, 0.f, 0.f); - for (joints_t::iterator iter = mChildren.begin(); - iter != mChildren.end(); ++iter) + for (LLJoint* joint : mChildren) { - LLJoint* joint = *iter; if (joint->isAnimatable()) { main_axis = joint->getPosition(); -- cgit v1.2.3 From 7419037ef6e8a5497283278baa8582b264d3aefa Mon Sep 17 00:00:00 2001 From: Fawrsk Date: Tue, 10 Jan 2023 05:43:27 -0400 Subject: SL-18893 Fixes for pull requests #38, #41, and #42 (#46) Eliminate unnecessary copies, and remove uses of auto --- indra/llcharacter/lljoint.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/llcharacter/lljoint.cpp') diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index 282db5c88b..280641a1a5 100644 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -67,7 +67,7 @@ void LLVector3OverrideMap::showJointVector3Overrides( std::ostringstream& os ) c map_type::const_iterator max_it = std::max_element(m_map.begin(), m_map.end(), attachment_map_iter_compare_key); - for (const map_type::value_type pos_pair : m_map) + for (const map_type::value_type& pos_pair : m_map) { const LLVector3& pos = pos_pair.second; os << " " << "[" << pos_pair.first <<": " << pos << "]" << ((pos_pair==(*max_it)) ? "*" : ""); @@ -509,7 +509,7 @@ void LLJoint::getAllAttachmentPosOverrides(S32& num_pos_overrides, std::set& distinct_pos_overrides) const { num_pos_overrides = m_attachmentPosOverrides.count(); - for (LLVector3OverrideMap::map_type::value_type pos_override_pair : m_attachmentPosOverrides.getMap()) + for (const LLVector3OverrideMap::map_type::value_type& pos_override_pair : m_attachmentPosOverrides.getMap()) { distinct_pos_overrides.insert(pos_override_pair.second); } @@ -522,7 +522,7 @@ void LLJoint::getAllAttachmentScaleOverrides(S32& num_scale_overrides, std::set& distinct_scale_overrides) const { num_scale_overrides = m_attachmentScaleOverrides.count(); - for (LLVector3OverrideMap::map_type::value_type scale_override_pair : m_attachmentScaleOverrides.getMap()) + for (const LLVector3OverrideMap::map_type::value_type& scale_override_pair : m_attachmentScaleOverrides.getMap()) { distinct_scale_overrides.insert(scale_override_pair.second); } @@ -549,7 +549,7 @@ void LLJoint::showAttachmentPosOverrides(const std::string& av_info) const { LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " has " << count << " attachment pos overrides" << LL_ENDL; std::set distinct_offsets; - for (LLVector3OverrideMap::map_type::value_type pos_override_pair : m_attachmentPosOverrides.getMap()) + for (const LLVector3OverrideMap::map_type::value_type& pos_override_pair : m_attachmentPosOverrides.getMap()) { distinct_offsets.insert(pos_override_pair.second); } @@ -708,7 +708,7 @@ void LLJoint::showAttachmentScaleOverrides(const std::string& av_info) const { LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " has " << count << " attachment scale overrides" << LL_ENDL; std::set distinct_offsets; - for (LLVector3OverrideMap::map_type::value_type scale_override_pair : m_attachmentScaleOverrides.getMap()) + for (const LLVector3OverrideMap::map_type::value_type& scale_override_pair : m_attachmentScaleOverrides.getMap()) { distinct_offsets.insert(scale_override_pair.second); } -- cgit v1.2.3 From 8ec8732ec9a6dd109b3d40762148f0c951566e9b Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Mon, 16 Jan 2023 23:07:51 +0200 Subject: SL-18893 OSX buildfix --- indra/llcharacter/lljoint.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/llcharacter/lljoint.cpp') diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index 280641a1a5..06f3bedf85 100644 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -720,7 +720,6 @@ void LLJoint::showAttachmentScaleOverrides(const std::string& av_info) const { LL_DEBUGS("Avatar") << "no conflicts" << LL_ENDL; } - std::set::iterator dit = distinct_offsets.begin(); for (const LLVector3& offset : distinct_offsets) { std::string highlight = (has_active_override && offset == active_override) ? "*" : ""; -- cgit v1.2.3