Do this the canonical way.

This commit is contained in:
JoelKatz
2012-02-16 14:37:13 -08:00
parent 370f969c7e
commit dc0f0a6576

View File

@@ -89,11 +89,7 @@ template<typename c_Key, typename c_Data> void TaggedCache<c_Key, c_Data>::sweep
while(cit!=mCache.end()) while(cit!=mCache.end())
{ {
if(cit->second->second.first<target) if(cit->second->second.first<target)
{ mCache.erase(cit++);
typename std::map<key_type, cache_entry>::iterator cit2=cit;
++cit;
mCache.erase(cit2);
}
else ++cit; else ++cit;
} }
@@ -102,11 +98,7 @@ template<typename c_Key, typename c_Data> void TaggedCache<c_Key, c_Data>::sweep
while(mit!=mMap.end()) while(mit!=mMap.end())
{ {
if(mit->second->expired()) if(mit->second->expired())
{ mMap.erase(mit++);
typename std::map<key_type, weak_data_ptr>::iterator mit2=mit;
++mit;
mMap.erase(mit2);
}
else ++mit; else ++mit;
} }
} }