Re: patch for address-book-vcard
- From: Berend De Schouwer <bds jhb ucs co za>
- To: Emmanuel <eallaud yahoo fr>
- Cc: balsa-list gnome org
- Subject: Re: patch for address-book-vcard
- Date: 19 Jun 2001 18:17:12 +0200
On 19 Jun 2001 09:11:21 +0200, Emmanuel wrote:
> Hi all,
> First part of the patch : just speed improvement;
>
> Second part :
> can someone explain me why we reverse completion_list after his creation
> instead of create it just in the right direction in this chunk of code
> (in libbalsa/address-book-vcard.c) ? :
>
> completion_list = NULL;
> while ( list ) {
> cmp_data = completion_data_new(LIBBALSA_ADDRESS(list->data),
> FALSE);
> completion_list = g_list_prepend(completion_list, cmp_data);
> list = g_list_next(list);
> }
> completion_list = g_list_reverse(completion_list);
Because this is faster than g_list_append(). Its faster because
prepending to a link list is O(1), and list_reverse is O(n). Appending
is O(n), and you need to do it n times, so it becomes O(n^2).
> If there is no good reason you can apply the second part of the
> straightforward patch I've attached.
> Bye
> Manu
> --AWniW0JNca5xppdA
Kind regards,
Berend
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Berend De Schouwer, +27-11-712-1435, UCS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]