Re: C question
- From: Nicolas GEORGE <nicolas george ens fr>
 
- To: gtk-list gnome org (Thames)
 
- Subject: Re: C question
 
- Date: Mon, 5 Jun 2000 21:09:05 +0200 (CEST)
 
Thames, dans le message (.gtk.general:3215), a écrit :
>    for(i=0; i <= g_list_length(items) - 1; i++) {
>      item_pointer = g_list_nth_data(items, i);
Warning: this part of code is quadratic: g_list_length and g_list_nth_data
are linear and called n times. You should use:
GList *temp_list;
for(temp_list=items; temp_list!=NULL; temp_list=temp_list->next){
  item_pointer=temp_list->data;
  ...
That excepted, your code seems perfect, and works perfectly. Except perarps
if the text you use is modified in place. In that cass you have to g_strdup
it, instead of only copying the pointer.
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]