summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-11-21 19:33:02 -0500
committerirungentoo <irungentoo@gmail.com>2013-11-21 19:33:02 -0500
commit2079cbc2db8ee98bcf2a0c66db8e503c705e5f95 (patch)
tree30a78c43222e92d61bfd3dd533dae98a5e942ccf
parentee3f91a8021193fd494af3f179361bb2acf6ad5e (diff)
Speed up group chat bootstrapping by a bit.
-rw-r--r--toxcore/Messenger.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index 73a1471c..8f6c42f9 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -736,7 +736,7 @@ static int group_num(Messenger *m, uint8_t *group_public_key)
736 for (i = 0; i < m->numchats; ++i) { 736 for (i = 0; i < m->numchats; ++i) {
737 if (m->chats[i] != NULL) 737 if (m->chats[i] != NULL)
738 if (id_equal(m->chats[i]->self_public_key, group_public_key)) 738 if (id_equal(m->chats[i]->self_public_key, group_public_key))
739 return i; 739 return i;
740 } 740 }
741 741
742 return -1; 742 return -1;
@@ -1672,7 +1672,7 @@ void do_friends(Messenger *m)
1672 break; 1672 break;
1673 1673
1674 group_newpeer(m->chats[groupnum], data + crypto_box_PUBLICKEYBYTES); 1674 group_newpeer(m->chats[groupnum], data + crypto_box_PUBLICKEYBYTES);
1675 1675 chat_bootstrap(m->chats[groupnum], get_friend_ipport(m, i), data + crypto_box_PUBLICKEYBYTES);
1676 break; 1676 break;
1677 } 1677 }
1678 1678
@@ -2182,13 +2182,13 @@ uint32_t count_chatlist(Messenger *m)
2182{ 2182{
2183 uint32_t ret = 0; 2183 uint32_t ret = 0;
2184 uint32_t i; 2184 uint32_t i;
2185 2185
2186 for (i = 0; i < m->numchats; i++) { 2186 for (i = 0; i < m->numchats; i++) {
2187 if (m->chats[i]) { 2187 if (m->chats[i]) {
2188 ret++; 2188 ret++;
2189 } 2189 }
2190 } 2190 }
2191 2191
2192 return ret; 2192 return ret;
2193} 2193}
2194 2194
@@ -2201,25 +2201,25 @@ uint32_t copy_chatlist(Messenger *m, int *out_list, uint32_t list_size)
2201{ 2201{
2202 if (!out_list) 2202 if (!out_list)
2203 return 0; 2203 return 0;
2204 2204
2205 if (m->numchats == 0) { 2205 if (m->numchats == 0) {
2206 return 0; 2206 return 0;
2207 } 2207 }
2208 2208
2209 uint32_t i; 2209 uint32_t i;
2210 uint32_t ret = 0; 2210 uint32_t ret = 0;
2211 2211
2212 for (i = 0; i < m->numchats; i++) { 2212 for (i = 0; i < m->numchats; i++) {
2213 if (ret >= list_size) { 2213 if (ret >= list_size) {
2214 break; /* Abandon ship */ 2214 break; /* Abandon ship */
2215 } 2215 }
2216 2216
2217 if (m->chats[i]) { 2217 if (m->chats[i]) {
2218 out_list[ret] = i; 2218 out_list[ret] = i;
2219 ret++; 2219 ret++;
2220 } 2220 }
2221 } 2221 }
2222 2222
2223 return ret; 2223 return ret;
2224} 2224}
2225 2225