From c1d2d5892eda3070975bbb82ac4f2e35d7bc139e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Wed, 26 Nov 2014 08:44:18 +0000 Subject: Facebook: Various optimizations and cleanup git-svn-id: http://svn.miranda-ng.org/main/trunk@11083 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/FacebookRM/src/contacts.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'protocols/FacebookRM/src/contacts.cpp') diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp index 7e76fdb4b7..5da990e616 100644 --- a/protocols/FacebookRM/src/contacts.cpp +++ b/protocols/FacebookRM/src/contacts.cpp @@ -22,7 +22,7 @@ along with this program. If not, see . #include "common.h" -void updateStringUtf(FacebookProto *proto, MCONTACT hContact, const char *key, std::string value) { +void updateStringUtf(FacebookProto *proto, MCONTACT hContact, const char *key, const std::string &value) { bool update_required = true; DBVARIANT dbv; @@ -52,7 +52,7 @@ void FacebookProto::SaveName(MCONTACT hContact, const facebook_user *fbu) updateStringUtf(this, hContact, FACEBOOK_KEY_FIRST_NAME, names.size() > 0 ? names.front().c_str() : ""); updateStringUtf(this, hContact, FACEBOOK_KEY_LAST_NAME, names.size() > 1 ? names.back().c_str() : ""); - std::string middle = ""; + std::string middle; if (names.size() > 2) { for (std::string::size_type i = 1; i < names.size() - 1; i++) { if (!middle.empty()) @@ -75,7 +75,7 @@ bool FacebookProto::IsMyContact(MCONTACT hContact, bool include_chat) return false; } -MCONTACT FacebookProto::ChatIDToHContact(std::tstring chat_id) +MCONTACT FacebookProto::ChatIDToHContact(const std::tstring &chat_id) { // First check cache std::map::iterator it = facy.chat_id_to_hcontact.find(chat_id); @@ -102,7 +102,7 @@ MCONTACT FacebookProto::ChatIDToHContact(std::tstring chat_id) return 0; } -MCONTACT FacebookProto::ContactIDToHContact(std::string user_id) +MCONTACT FacebookProto::ContactIDToHContact(const std::string &user_id) { // First check cache std::map::iterator it = facy.user_id_to_hcontact.find(user_id); @@ -129,7 +129,7 @@ MCONTACT FacebookProto::ContactIDToHContact(std::string user_id) return 0; } -std::string FacebookProto::ThreadIDToContactID(std::string thread_id) +std::string FacebookProto::ThreadIDToContactID(const std::string &thread_id) { // First check cache std::map::iterator it = facy.thread_id_to_user_id.find(thread_id); @@ -164,7 +164,7 @@ std::string FacebookProto::ThreadIDToContactID(std::string thread_id) data += "&__a=1&__dyn=&__req=&ttstamp=" + facy.ttstamp(); data += "&threads[thread_ids][0]=" + utils::url::encode(thread_id); - std::string user_id = ""; + std::string user_id; http::response resp = facy.flap(REQUEST_THREAD_INFO, &data); if (resp.code == HTTP_CODE_OK) { @@ -277,7 +277,9 @@ void FacebookProto::LoadChatInfo(facebook_chatroom *fbc) unsigned int namesCount = 3; // how many names should be in room name; max. 5 for (std::map::iterator it = fbc->participants.begin(); it != fbc->participants.end(); ++it) { - if (it->second.empty()) + std::string participant = it->second; + + if (participant.empty()) continue; if (!fbc->chat_name.empty()) @@ -285,11 +287,11 @@ void FacebookProto::LoadChatInfo(facebook_chatroom *fbc) std::string name; std::string::size_type pos; - if ((pos = it->second.find(" ")) != std::string::npos) { - name = it->second.substr(0, pos); + if ((pos = participant.find(" ")) != std::string::npos) { + name = participant.substr(0, pos); } else { - name = it->second; + name = participant; } fbc->chat_name += _A2T(name.c_str()); -- cgit v1.2.3