mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-17 10:31:05 -04:00
Optimized p3HistoryMgr::cleanOldMessages.
There is no need to check the messages when mMaxStorageDurationSeconds is set to 0. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6779 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
4e259fecfd
commit
571099d56b
1 changed files with 16 additions and 13 deletions
|
@ -157,22 +157,25 @@ void p3HistoryMgr::cleanOldMessages()
|
||||||
|
|
||||||
for(std::map<std::string, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.begin(); mit != mMessages.end();)
|
for(std::map<std::string, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.begin(); mit != mMessages.end();)
|
||||||
{
|
{
|
||||||
for(std::map<uint32_t, RsHistoryMsgItem*>::iterator lit = mit->second.begin();lit!=mit->second.end();)
|
if (mMaxStorageDurationSeconds > 0)
|
||||||
if(mMaxStorageDurationSeconds > 0 && lit->second->recvTime + mMaxStorageDurationSeconds < now)
|
{
|
||||||
{
|
for(std::map<uint32_t, RsHistoryMsgItem*>::iterator lit = mit->second.begin();lit!=mit->second.end();)
|
||||||
std::map<uint32_t, RsHistoryMsgItem*>::iterator lit2 = lit ;
|
if(lit->second->recvTime + mMaxStorageDurationSeconds < now)
|
||||||
++lit2 ;
|
{
|
||||||
|
std::map<uint32_t, RsHistoryMsgItem*>::iterator lit2 = lit ;
|
||||||
|
++lit2 ;
|
||||||
|
|
||||||
std::cerr << " removing msg id " << lit->first << ", for peer id " << mit->first << std::endl;
|
std::cerr << " removing msg id " << lit->first << ", for peer id " << mit->first << std::endl;
|
||||||
delete lit->second ;
|
delete lit->second ;
|
||||||
|
|
||||||
mit->second.erase(lit) ;
|
mit->second.erase(lit) ;
|
||||||
lit = lit2 ;
|
lit = lit2 ;
|
||||||
|
|
||||||
changed = true ;
|
changed = true ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
++lit ;
|
++lit ;
|
||||||
|
}
|
||||||
|
|
||||||
if(mit->second.empty())
|
if(mit->second.empty())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue