optimize perf

This commit is contained in:
Benjamin Reis 2017-01-20 09:35:14 +01:00
parent b4479fb4d4
commit 07695c3c64

View file

@ -499,7 +499,13 @@ static LinphoneFriendListStatus _linphone_friend_list_add_friend(LinphoneFriendL
return status;
}
addr = linphone_friend_get_address(lf);
if (bctbx_list_find(list->friends, lf) != NULL) {
bool_t present_in_map= FALSE;
if (lf->refkey) {
if(linphone_friend_list_find_friend_by_ref_key(list, lf->refkey)) {
present_in_map = TRUE;
}
}
if (present_in_map || bctbx_list_find(list->friends, lf) != NULL) {
char *tmp = NULL;
if (addr) tmp = linphone_address_as_string(addr);
ms_warning("Friend %s already in list [%s], ignored.", tmp ? tmp : "unknown", list->display_name);
@ -538,7 +544,7 @@ LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList *
bctbx_map_cchar_insert_and_delete(list->friends_map, pair);
}
if (synchronize) {
list->dirty_friends_to_update = bctbx_list_append(list->dirty_friends_to_update, linphone_friend_ref(lf));
list->dirty_friends_to_update = bctbx_list_prepend(list->dirty_friends_to_update, linphone_friend_ref(lf));
}
return LinphoneFriendListOK;
}