← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2999: fix useless remove_if calls

 

------------------------------------------------------------
revno: 2999
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Fri 2012-07-13 21:41:18 +0200
message:
  fix useless remove_if calls
modified:
  dcpp/FavoriteManager.cpp
  dcpp/Util.h


--
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 'dcpp/FavoriteManager.cpp'
--- dcpp/FavoriteManager.cpp	2012-07-13 18:11:14 +0000
+++ dcpp/FavoriteManager.cpp	2012-07-13 19:41:18 +0000
@@ -143,16 +143,16 @@
 }
 void FavoriteManager::removeUserCommand(const string& srv) {
 	Lock l(cs);
-	std::remove_if(userCommands.begin(), userCommands.end(), [&](const UserCommand& uc) -> bool {
+	userCommands.erase(std::remove_if(userCommands.begin(), userCommands.end(), [&](const UserCommand& uc) {
 		return uc.getHub() == srv && uc.isSet(UserCommand::FLAG_NOSAVE);
-	});
+	}), userCommands.end());
 }
 
 void FavoriteManager::removeHubUserCommands(int ctx, const string& hub) {
 	Lock l(cs);
-	std::remove_if(userCommands.begin(), userCommands.end(), [&](const UserCommand& uc) -> bool {
+	userCommands.erase(std::remove_if(userCommands.begin(), userCommands.end(), [&](const UserCommand& uc) {
 		return uc.getHub() == hub && uc.isSet(UserCommand::FLAG_NOSAVE) && uc.getCtx() & ctx;
-	});
+	}), userCommands.end());
 }
 
 void FavoriteManager::addFavoriteUser(const UserPtr& aUser) {

=== modified file 'dcpp/Util.h'
--- dcpp/Util.h	2012-07-13 18:50:28 +0000
+++ dcpp/Util.h	2012-07-13 19:41:18 +0000
@@ -398,9 +398,9 @@
 
 	template<typename T>
 	static T& intersect(T& t1, const T& t2) {
-		boost::remove_if(t1, [&](const typename T::value_type& v1) {
+		t1.erase(boost::remove_if(t1, [&](const typename T::value_type& v1) {
 			return boost::find_if(t2, [&](const typename T::value_type& v2) { return v2 == v1; }) == t2.end();
-		});
+		}), t1.end());
 		return t1;
 	}