linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #05802
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2967: Greatly improve user command removal time when closing a hub
------------------------------------------------------------
revno: 2967
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Thu 2012-06-28 19:27:42 +0200
message:
Greatly improve user command removal time when closing a hub
modified:
changelog.txt
dcpp/FavoriteManager.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt 2012-06-23 20:38:05 +0000
+++ changelog.txt 2012-06-28 17:27:42 +0000
@@ -21,6 +21,7 @@
* [L#1016205] Avoid deadlocks when changing user matchings (poy)
* [L#249159] Improve performance when selecting lots of lines in lists (poy)
* [L#1016907] Exclude temporary downloads from queue dupe check (emtee)
+* Greatly improve user command removal time when closing a hub
-- 0.799 2012-05-05 --
* Add icons (iceman50)
=== modified file 'dcpp/FavoriteManager.cpp'
--- dcpp/FavoriteManager.cpp 2012-06-20 09:02:43 +0000
+++ dcpp/FavoriteManager.cpp 2012-06-28 17:27:42 +0000
@@ -127,6 +127,7 @@
void FavoriteManager::removeUserCommand(int cid) {
bool nosave = true;
Lock l(cs);
+
for(auto i = userCommands.begin(); i != userCommands.end(); ++i) {
if(i->getId() == cid) {
nosave = i->isSet(UserCommand::FLAG_NOSAVE);
@@ -134,29 +135,24 @@
break;
}
}
- if(!nosave)
+
+ if(!nosave) {
+ l.unlock();
save();
+ }
}
void FavoriteManager::removeUserCommand(const string& srv) {
Lock l(cs);
- for(auto i = userCommands.begin(); i != userCommands.end(); ) {
- if((i->getHub() == srv) && i->isSet(UserCommand::FLAG_NOSAVE)) {
- i = userCommands.erase(i);
- } else {
- ++i;
- }
- }
+ std::remove_if(userCommands.begin(), userCommands.end(), [&](const UserCommand& uc) -> bool {
+ return uc.getHub() == srv && uc.isSet(UserCommand::FLAG_NOSAVE);
+ });
}
void FavoriteManager::removeHubUserCommands(int ctx, const string& hub) {
Lock l(cs);
- for(auto i = userCommands.begin(); i != userCommands.end(); ) {
- if(i->getHub() == hub && i->isSet(UserCommand::FLAG_NOSAVE) && i->getCtx() & ctx) {
- i = userCommands.erase(i);
- } else {
- ++i;
- }
- }
+ std::remove_if(userCommands.begin(), userCommands.end(), [&](const UserCommand& uc) -> bool {
+ return uc.getHub() == hub && uc.isSet(UserCommand::FLAG_NOSAVE) && uc.getCtx() == ctx;
+ });
}
void FavoriteManager::addFavoriteUser(const UserPtr& aUser) {