group: improve flow view performance for one call groups

This commit is contained in:
Kaian 2018-06-07 20:52:59 +02:00
parent d4a41b26fa
commit aaebd2d801
1 changed files with 44 additions and 28 deletions

View File

@ -224,9 +224,15 @@ sip_msg_t *
call_group_get_next_msg(sip_call_group_t *group, sip_msg_t *msg)
{
sip_msg_t *next;
if (call_group_count(group) == 1) {
sip_call_t *call = vector_first(group->calls);
vector_iter_t it = vector_iterator(call->msgs);
vector_iterator_set_current(&it, vector_index(call->msgs, msg));
next = vector_iterator_next(&it);
} else {
vector_t *messages = vector_create(1,10);
vector_set_sorter(messages, call_group_msg_sorter);
vector_iter_t callsit = vector_iterator(group->calls);
sip_call_t *call;
while ((call = vector_iterator_next(&callsit))) {
@ -239,8 +245,9 @@ call_group_get_next_msg(sip_call_group_t *group, sip_msg_t *msg)
next = vector_item(messages, vector_index(messages, msg) + 1);
}
vector_destroy(messages);
next = sip_parse_msg(next);
}
next = sip_parse_msg(next);
if (next && group->sdp_only && !msg_has_sdp(next)) {
return call_group_get_next_msg(group, next);
}
@ -252,9 +259,17 @@ sip_msg_t *
call_group_get_prev_msg(sip_call_group_t *group, sip_msg_t *msg)
{
sip_msg_t *prev;
if (call_group_count(group) == 1) {
sip_call_t *call = vector_first(group->calls);
vector_iter_t it = vector_iterator(call->msgs);
vector_iterator_set_current(&it, vector_index(call->msgs, msg));
prev = vector_iterator_prev(&it);
} else {
vector_t *messages = vector_create(1, 10);
vector_set_sorter(messages, call_group_msg_sorter);
vector_iter_t callsit = vector_iterator(group->calls);
sip_call_t *call;
while ((call = vector_iterator_next(&callsit))) {
@ -267,8 +282,9 @@ call_group_get_prev_msg(sip_call_group_t *group, sip_msg_t *msg)
prev = vector_item(messages, vector_index(messages, msg) - 1);
}
vector_destroy(messages);
prev = sip_parse_msg(prev);
}
prev = sip_parse_msg(prev);
if (prev && group->sdp_only && !msg_has_sdp(prev)) {
return call_group_get_prev_msg(group, prev);
}