mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
remove three costly loops in ftController
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6833 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
a8c250e7d9
commit
7876001be3
@ -164,23 +164,21 @@ void ftController::addFileSource(const std::string& hash,const std::string& peer
|
|||||||
{
|
{
|
||||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||||
|
|
||||||
std::map<std::string, ftFileControl*>::iterator it;
|
std::map<std::string, ftFileControl*>::iterator it = mDownloads.find(hash);
|
||||||
std::map<std::string, ftFileControl*> currentDownloads = *(&mDownloads);
|
|
||||||
|
|
||||||
#ifdef CONTROL_DEBUG
|
#ifdef CONTROL_DEBUG
|
||||||
std::cerr << "ftController: Adding source " << peer_id << " to current download hash=" << hash ;
|
std::cerr << "ftController: Adding source " << peer_id << " to current download hash=" << hash ;
|
||||||
#endif
|
#endif
|
||||||
for(it = currentDownloads.begin(); it != currentDownloads.end(); it++)
|
if(it != mDownloads.end())
|
||||||
if(it->first == hash)
|
{
|
||||||
{
|
it->second->mTransfer->addFileSource(peer_id);
|
||||||
it->second->mTransfer->addFileSource(peer_id);
|
setPeerState(it->second->mTransfer, peer_id, FT_CNTRL_STANDARD_RATE, mLinkMgr->isOnline( peer_id ));
|
||||||
setPeerState(it->second->mTransfer, peer_id, FT_CNTRL_STANDARD_RATE, mLinkMgr->isOnline( peer_id ));
|
|
||||||
|
|
||||||
#ifdef CONTROL_DEBUG
|
#ifdef CONTROL_DEBUG
|
||||||
std::cerr << "... added." << std::endl ;
|
std::cerr << "... added." << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
#ifdef CONTROL_DEBUG
|
#ifdef CONTROL_DEBUG
|
||||||
std::cerr << "... not added: hash not found." << std::endl ;
|
std::cerr << "... not added: hash not found." << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
@ -189,23 +187,21 @@ void ftController::removeFileSource(const std::string& hash,const std::string& p
|
|||||||
{
|
{
|
||||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||||
|
|
||||||
std::map<std::string, ftFileControl*>::iterator it;
|
std::map<std::string, ftFileControl*>::iterator it = mDownloads.find(hash);
|
||||||
std::map<std::string, ftFileControl*> currentDownloads = *(&mDownloads);
|
|
||||||
|
|
||||||
#ifdef CONTROL_DEBUG
|
#ifdef CONTROL_DEBUG
|
||||||
std::cerr << "ftController: Adding source " << peer_id << " to current download hash=" << hash ;
|
std::cerr << "ftController: Adding source " << peer_id << " to current download hash=" << hash ;
|
||||||
#endif
|
#endif
|
||||||
for(it = currentDownloads.begin(); it != currentDownloads.end(); it++)
|
if(it != mDownloads.end())
|
||||||
if(it->first == hash)
|
{
|
||||||
{
|
it->second->mTransfer->removeFileSource(peer_id);
|
||||||
it->second->mTransfer->removeFileSource(peer_id);
|
it->second->mCreator->removeFileSource(peer_id);
|
||||||
it->second->mCreator->removeFileSource(peer_id);
|
|
||||||
|
|
||||||
#ifdef CONTROL_DEBUG
|
#ifdef CONTROL_DEBUG
|
||||||
std::cerr << "... added." << std::endl ;
|
std::cerr << "... added." << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
#ifdef CONTROL_DEBUG
|
#ifdef CONTROL_DEBUG
|
||||||
std::cerr << "... not added: hash not found." << std::endl ;
|
std::cerr << "... not added: hash not found." << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
@ -1819,6 +1815,7 @@ void ftController::statusChange(const std::list<pqipeer> &plist)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
for(it = mDownloads.begin(); it != mDownloads.end(); it++)
|
for(it = mDownloads.begin(); it != mDownloads.end(); it++)
|
||||||
|
if(it->second->mState == ftFileControl::DOWNLOADING)
|
||||||
{
|
{
|
||||||
#ifdef CONTROL_DEBUG
|
#ifdef CONTROL_DEBUG
|
||||||
std::cerr << "ftController::statusChange() Updating Hash:";
|
std::cerr << "ftController::statusChange() Updating Hash:";
|
||||||
|
Loading…
Reference in New Issue
Block a user