← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3204: more efficient lookup

 

------------------------------------------------------------
revno: 3204
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Mon 2013-02-04 19:42:31 +0100
message:
  more efficient lookup
modified:
  dcpp/ClientManager.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 'dcpp/ClientManager.cpp'
--- dcpp/ClientManager.cpp	2013-02-03 22:26:48 +0000
+++ dcpp/ClientManager.cpp	2013-02-04 18:42:31 +0000
@@ -199,10 +199,11 @@
 	Lock l(cs);
 
 	string ip;
-	string port = "411";
+	string port;
 	string::size_type i = ipPort.rfind(':');
 	if(i == string::npos) {
 		ip = ipPort;
+		port = "411";
 	} else {
 		ip = ipPort.substr(0, i);
 		port = ipPort.substr(i+1);
@@ -240,14 +241,14 @@
 
 	Lock l(cs);
 
-	for(auto& i: onlineUsers) {
-		auto& ou = *i.second;
-		if(ou.getUser()->isSet(User::NMDC) &&
-			/** @todo this conv runs each time on ever user; remove it when we store non-UTF-8
-			nicks as well... */
-			Util::stricmp(ou.getIdentity().getNick(), Text::toUtf8(nick, ou.getClient().getEncoding())) == 0)
-		{
-			return HintedUser(ou);
+	for(auto i: clients) {
+		auto nmdc = dynamic_cast<NmdcHub*>(i);
+		if(nmdc) {
+			/** @todo run the search directly on non-UTF-8 nicks when we store them. */
+			auto ou = nmdc->findUser(nmdc->toUtf8(nick));
+			if(ou) {
+				return HintedUser(*ou);
+			}
 		}
 	}