diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-11-26 08:44:18 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-11-26 08:44:18 +0000 |
commit | c1d2d5892eda3070975bbb82ac4f2e35d7bc139e (patch) | |
tree | 5902759b93eed462f1b8815a19b9f9e35d674046 /protocols/FacebookRM/src/contacts.cpp | |
parent | f5e38aaba573fa720894433ae746b3a7a741356e (diff) |
Facebook: Various optimizations and cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@11083 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/contacts.cpp')
-rw-r--r-- | protocols/FacebookRM/src/contacts.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
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 <http://www.gnu.org/licenses/>. #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<std::tstring, MCONTACT>::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<std::string, MCONTACT>::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<std::string, std::string>::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<std::string, std::string>::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()); |