Use ranged for loops in GenericObjectCache

macos_ci_fix
elsid 5 months ago
parent 2f0613c8d4
commit 7b1ee2780b
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -139,26 +139,18 @@ namespace Resource
void releaseGLObjects(osg::State* state)
{
std::lock_guard<std::mutex> lock(_objectCacheMutex);
for (typename ObjectCacheMap::iterator itr = _objectCache.begin(); itr != _objectCache.end(); ++itr)
{
osg::Object* object = itr->second.mValue.get();
object->releaseGLObjects(state);
}
for (const auto& [k, v] : _objectCache)
v.mValue->releaseGLObjects(state);
}
/** call node->accept(nv); for all nodes in the objectCache. */
void accept(osg::NodeVisitor& nv)
{
std::lock_guard<std::mutex> lock(_objectCacheMutex);
for (typename ObjectCacheMap::iterator itr = _objectCache.begin(); itr != _objectCache.end(); ++itr)
{
if (osg::Object* object = itr->second.mValue.get())
{
osg::Node* node = dynamic_cast<osg::Node*>(object);
if (node)
for (const auto& [k, v] : _objectCache)
if (osg::Object* const object = v.mValue.get())
if (osg::Node* const node = dynamic_cast<osg::Node*>(object))
node->accept(nv);
}
}
}
/** call operator()(KeyType, osg::Object*) for each object in the cache. */
@ -166,8 +158,8 @@ namespace Resource
void call(Functor&& f)
{
std::lock_guard<std::mutex> lock(_objectCacheMutex);
for (typename ObjectCacheMap::iterator it = _objectCache.begin(); it != _objectCache.end(); ++it)
f(it->first, it->second.mValue.get());
for (const auto& [k, v] : _objectCache)
f(k, v.mValue.get());
}
/** Get the number of objects in the cache. */

Loading…
Cancel
Save