From 9522a0b7c16414fce2103cf58bfdd63aaf0cb01b Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 3 Nov 2022 14:58:32 -0400 Subject: DRTVWR-575: Fix llcommon assumptions that size_t fits in 4 bytes. It's a little distressing how often we have historically coded S32 or U32 to pass a length or index. There are more such assumptions in other viewer subdirectories, but this is a start. --- indra/llcommon/lldependencies.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/lldependencies.h') diff --git a/indra/llcommon/lldependencies.h b/indra/llcommon/lldependencies.h index db2bbab8b0..950af4a4ad 100644 --- a/indra/llcommon/lldependencies.h +++ b/indra/llcommon/lldependencies.h @@ -126,7 +126,7 @@ public: protected: typedef std::vector< std::pair > EdgeList; typedef std::vector VertexList; - VertexList topo_sort(int vertices, const EdgeList& edges) const; + VertexList topo_sort(size_t vertices, const EdgeList& edges) const; /** * refpair is specifically intended to capture a pair of references. This @@ -539,7 +539,7 @@ public: for (typename DepNodeMap::const_iterator nmi = mNodes.begin(), nmend = mNodes.end(); nmi != nmend; ++nmi) { - int thisnode = vmap[nmi->first]; + auto thisnode = vmap[nmi->first]; // after dependencies: build edges from the named node to this one for (typename DepNode::dep_set::const_iterator ai = nmi->second.after.begin(), aend = nmi->second.after.end(); -- cgit v1.2.3 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/lldependencies.h | 46 +++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 29 deletions(-) (limited to 'indra/llcommon/lldependencies.h') diff --git a/indra/llcommon/lldependencies.h b/indra/llcommon/lldependencies.h index 950af4a4ad..ba5fcb195c 100644 --- a/indra/llcommon/lldependencies.h +++ b/indra/llcommon/lldependencies.h @@ -514,21 +514,16 @@ public: // former broken behavior has finally been fixed -- and our builds // treat warnings as errors. { - for (typename DepNodeMap::const_iterator nmi = mNodes.begin(), nmend = mNodes.end(); - nmi != nmend; ++nmi) + for (typename const DepNodeMap::value_type nm_pair : mNodes) { - vmap.insert(typename VertexMap::value_type(nmi->first, vmap.size())); - for (typename DepNode::dep_set::const_iterator ai = nmi->second.after.begin(), - aend = nmi->second.after.end(); - ai != aend; ++ai) + vmap.insert(typename VertexMap::value_type(nm_pair.first, vmap.size())); + for (typename const KEY& after_k : nm_pair.second.after) { - vmap.insert(typename VertexMap::value_type(*ai, vmap.size())); + vmap.insert(typename VertexMap::value_type(after_k, vmap.size())); } - for (typename DepNode::dep_set::const_iterator bi = nmi->second.before.begin(), - bend = nmi->second.before.end(); - bi != bend; ++bi) + for (typename const KEY& before_k : nm_pair.second.before) { - vmap.insert(typename VertexMap::value_type(*bi, vmap.size())); + vmap.insert(typename VertexMap::value_type(before_k, vmap.size())); } } } @@ -536,24 +531,19 @@ public: // all the known key dependencies to integer pairs. EdgeList edges; { - for (typename DepNodeMap::const_iterator nmi = mNodes.begin(), nmend = mNodes.end(); - nmi != nmend; ++nmi) + for (typename const DepNodeMap::value_type nm_pair : mNodes) { - auto thisnode = vmap[nmi->first]; + auto thisnode = vmap[nm_pair.first]; // after dependencies: build edges from the named node to this one - for (typename DepNode::dep_set::const_iterator ai = nmi->second.after.begin(), - aend = nmi->second.after.end(); - ai != aend; ++ai) + for (typename const KEY& after_k : nm_pair.second.after) { - edges.push_back(EdgeList::value_type(vmap[*ai], thisnode)); + edges.push_back(EdgeList::value_type(vmap[after_k], thisnode)); } // before dependencies: build edges from this node to the // named one - for (typename DepNode::dep_set::const_iterator bi = nmi->second.before.begin(), - bend = nmi->second.before.end(); - bi != bend; ++bi) + for (typename const KEY& before_k : nm_pair.second.before) { - edges.push_back(EdgeList::value_type(thisnode, vmap[*bi])); + edges.push_back(EdgeList::value_type(thisnode, vmap[before_k])); } } } @@ -565,21 +555,19 @@ public: // and we're certain that the associated int values are distinct // indexes. The fact that they're not in order is irrelevant. KeyList vkeys(vmap.size()); - for (typename VertexMap::const_iterator vmi = vmap.begin(), vmend = vmap.end(); - vmi != vmend; ++vmi) + for (typename const VertexMap::value_type vm_pair : vmap) { - vkeys[vmi->second] = vmi->first; + vkeys[vm_pair.second] = vm_pair.first; } // Walk the sorted output list, building the result into mCache so // we'll have it next time someone asks. mCache.clear(); - for (VertexList::const_iterator svi = sorted.begin(), svend = sorted.end(); - svi != svend; ++svi) + for (const size_t sv : sorted) { - // We're certain that vkeys[*svi] exists. However, there might not + // We're certain that vkeys[sv] exists. However, there might not // yet be a corresponding entry in mNodes. self_type* non_const_this(const_cast(this)); - typename DepNodeMap::iterator found = non_const_this->mNodes.find(vkeys[*svi]); + typename DepNodeMap::iterator found = non_const_this->mNodes.find(vkeys[sv]); if (found != non_const_this->mNodes.end()) { // Make an iterator of appropriate type. -- 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/lldependencies.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/lldependencies.h') diff --git a/indra/llcommon/lldependencies.h b/indra/llcommon/lldependencies.h index ba5fcb195c..fa54a944c8 100644 --- a/indra/llcommon/lldependencies.h +++ b/indra/llcommon/lldependencies.h @@ -514,7 +514,7 @@ public: // former broken behavior has finally been fixed -- and our builds // treat warnings as errors. { - for (typename const DepNodeMap::value_type nm_pair : mNodes) + for (typename const DepNodeMap::value_type& nm_pair : mNodes) { vmap.insert(typename VertexMap::value_type(nm_pair.first, vmap.size())); for (typename const KEY& after_k : nm_pair.second.after) @@ -531,7 +531,7 @@ public: // all the known key dependencies to integer pairs. EdgeList edges; { - for (typename const DepNodeMap::value_type nm_pair : mNodes) + for (typename const DepNodeMap::value_type& nm_pair : mNodes) { auto thisnode = vmap[nm_pair.first]; // after dependencies: build edges from the named node to this one @@ -555,7 +555,7 @@ public: // and we're certain that the associated int values are distinct // indexes. The fact that they're not in order is irrelevant. KeyList vkeys(vmap.size()); - for (typename const VertexMap::value_type vm_pair : vmap) + for (typename const VertexMap::value_type& vm_pair : vmap) { vkeys[vm_pair.second] = vm_pair.first; } -- 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/llcommon/lldependencies.h | 46 ++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 17 deletions(-) (limited to 'indra/llcommon/lldependencies.h') diff --git a/indra/llcommon/lldependencies.h b/indra/llcommon/lldependencies.h index fa54a944c8..950af4a4ad 100644 --- a/indra/llcommon/lldependencies.h +++ b/indra/llcommon/lldependencies.h @@ -514,16 +514,21 @@ public: // former broken behavior has finally been fixed -- and our builds // treat warnings as errors. { - for (typename const DepNodeMap::value_type& nm_pair : mNodes) + for (typename DepNodeMap::const_iterator nmi = mNodes.begin(), nmend = mNodes.end(); + nmi != nmend; ++nmi) { - vmap.insert(typename VertexMap::value_type(nm_pair.first, vmap.size())); - for (typename const KEY& after_k : nm_pair.second.after) + vmap.insert(typename VertexMap::value_type(nmi->first, vmap.size())); + for (typename DepNode::dep_set::const_iterator ai = nmi->second.after.begin(), + aend = nmi->second.after.end(); + ai != aend; ++ai) { - vmap.insert(typename VertexMap::value_type(after_k, vmap.size())); + vmap.insert(typename VertexMap::value_type(*ai, vmap.size())); } - for (typename const KEY& before_k : nm_pair.second.before) + for (typename DepNode::dep_set::const_iterator bi = nmi->second.before.begin(), + bend = nmi->second.before.end(); + bi != bend; ++bi) { - vmap.insert(typename VertexMap::value_type(before_k, vmap.size())); + vmap.insert(typename VertexMap::value_type(*bi, vmap.size())); } } } @@ -531,19 +536,24 @@ public: // all the known key dependencies to integer pairs. EdgeList edges; { - for (typename const DepNodeMap::value_type& nm_pair : mNodes) + for (typename DepNodeMap::const_iterator nmi = mNodes.begin(), nmend = mNodes.end(); + nmi != nmend; ++nmi) { - auto thisnode = vmap[nm_pair.first]; + auto thisnode = vmap[nmi->first]; // after dependencies: build edges from the named node to this one - for (typename const KEY& after_k : nm_pair.second.after) + for (typename DepNode::dep_set::const_iterator ai = nmi->second.after.begin(), + aend = nmi->second.after.end(); + ai != aend; ++ai) { - edges.push_back(EdgeList::value_type(vmap[after_k], thisnode)); + edges.push_back(EdgeList::value_type(vmap[*ai], thisnode)); } // before dependencies: build edges from this node to the // named one - for (typename const KEY& before_k : nm_pair.second.before) + for (typename DepNode::dep_set::const_iterator bi = nmi->second.before.begin(), + bend = nmi->second.before.end(); + bi != bend; ++bi) { - edges.push_back(EdgeList::value_type(thisnode, vmap[before_k])); + edges.push_back(EdgeList::value_type(thisnode, vmap[*bi])); } } } @@ -555,19 +565,21 @@ public: // and we're certain that the associated int values are distinct // indexes. The fact that they're not in order is irrelevant. KeyList vkeys(vmap.size()); - for (typename const VertexMap::value_type& vm_pair : vmap) + for (typename VertexMap::const_iterator vmi = vmap.begin(), vmend = vmap.end(); + vmi != vmend; ++vmi) { - vkeys[vm_pair.second] = vm_pair.first; + vkeys[vmi->second] = vmi->first; } // Walk the sorted output list, building the result into mCache so // we'll have it next time someone asks. mCache.clear(); - for (const size_t sv : sorted) + for (VertexList::const_iterator svi = sorted.begin(), svend = sorted.end(); + svi != svend; ++svi) { - // We're certain that vkeys[sv] exists. However, there might not + // We're certain that vkeys[*svi] exists. However, there might not // yet be a corresponding entry in mNodes. self_type* non_const_this(const_cast(this)); - typename DepNodeMap::iterator found = non_const_this->mNodes.find(vkeys[sv]); + typename DepNodeMap::iterator found = non_const_this->mNodes.find(vkeys[*svi]); if (found != non_const_this->mNodes.end()) { // Make an iterator of appropriate type. -- cgit v1.2.3