Hi Ronald,

>  src/service.c |   27 +++++++++++++++++++++++++++
>  1 files changed, 27 insertions(+), 0 deletions(-)
> 
> diff --git a/src/service.c b/src/service.c
> index 2787c3a..1bd4671 100644
> --- a/src/service.c
> +++ b/src/service.c
> @@ -719,6 +719,31 @@ static gboolean get_conversation_get_args(DBusMessage 
> *dbus_msg,
>       return TRUE;
>  }
> 
> +static gint fill_conversation_sort(gconstpointer a, gconstpointer b)
> +{
> +     const struct mms_message *msg1 = a;
> +     const struct mms_message *msg2 = b;
> +     time_t date1, date2;
> +
> +     if (msg1->type == MMS_MESSAGE_TYPE_SEND_REQ)
> +             date1 = msg1->sr.date;
> +     else
> +             date1 = msg1->rc.date;
> +
> +     if (msg2->type == MMS_MESSAGE_TYPE_SEND_REQ)
> +             date2 = msg2->sr.date;
> +     else
> +             date2 = msg2->rc.date;
> +
> +     if (date1 > date2)
> +             return 1;
> +
> +     if (date1 < date2)
> +             return -1;
> +
> +     return 0;
> +}
> +
>  static gboolean is_recipient(const char *recipients, const char *number)
>  {
>       const char *rec, *num;
> @@ -784,6 +809,8 @@ static GList *fill_conversation(const struct mms_service 
> *service,
>                       conversation = g_list_prepend(conversation, value);
>       }
> 
> +     conversation = g_list_sort(conversation, fill_conversation_sort);
> +

is it really more efficient to prepend and then later sort the list? Can
we just not insert items sorted to begin with?

Regards

Marcel


_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to