Ethereal-dev: Re: [ethereal-dev] I hate GLists
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Guy Harris <guy@xxxxxxxxxx>
Date: Wed, 25 Aug 1999 20:56:30 -0700 (PDT)
> Unfortunately, unlike my previous changes to get rid of that flavor of
> N^2 behavior, by avoiding calls to set attributes of lines in the CList
> as they're built (as those calls use "g_list_nth()"), that one doesn't
> looks so easy to fix without changing GTK+. I'll see if I can have the
> CList remember the row number of the most recently added item, and a
> pointer to that item, and use that as a cache to avoid calling
> "g_list_nth()", or something such as that.
Those of you who are feeling daring could apply the following change to
"gtk/gtkclist.c" in the GTK 1.2[.x] source; it took "g_list_nth()" off
the top of the CPU Eaters list (leaving "internal_mcount" at the top,
i.e. the biggest consumer of CPU is now a routine that keeps track of
who's calling whom so you can figure out where the CPU time is
going...).
I'll see what's involved in sending this off to the GTK+ maintainers.
(It doesn't eliminate "g_list_nth()", but it does mean you don't need it
to find the data for the last row in the CList, and, when building a
list, that's the row we do things to after we've added it to the list,
so it reduces "g_list_nth()" to a minor player.)
*** gtkclist.c 1999/06/11 21:13:48 1.1
--- gtkclist.c 1999/08/26 03:43:29
***************
*** 2169,2175 ****
if (column < 0 || column >= clist->columns)
return -1;
! clist_row = (g_list_nth (clist->row_list, row))->data;
return clist_row->cell[column].type;
}
--- 2169,2178 ----
if (column < 0 || column >= clist->columns)
return -1;
! if (row == clist->rows - 1)
! clist_row = clist->row_list_end->data;
! else
! clist_row = (g_list_nth (clist->row_list, row))->data;
return clist_row->cell[column].type;
}
***************
*** 2190,2196 ****
if (column < 0 || column >= clist->columns)
return;
! clist_row = (g_list_nth (clist->row_list, row))->data;
/* if text is null, then the cell is empty */
GTK_CLIST_CLASS_FW (clist)->set_cell_contents
--- 2193,2202 ----
if (column < 0 || column >= clist->columns)
return;
! if (row == clist->rows - 1)
! clist_row = clist->row_list_end->data;
! else
! clist_row = (g_list_nth (clist->row_list, row))->data;
/* if text is null, then the cell is empty */
GTK_CLIST_CLASS_FW (clist)->set_cell_contents
***************
*** 2220,2226 ****
if (column < 0 || column >= clist->columns)
return 0;
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (clist_row->cell[column].type != GTK_CELL_TEXT)
return 0;
--- 2226,2235 ----
if (column < 0 || column >= clist->columns)
return 0;
! if (row == clist->rows - 1)
! clist_row = clist->row_list_end->data;
! else
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (clist_row->cell[column].type != GTK_CELL_TEXT)
return 0;
***************
*** 2248,2254 ****
if (column < 0 || column >= clist->columns)
return;
! clist_row = (g_list_nth (clist->row_list, row))->data;
gdk_pixmap_ref (pixmap);
--- 2257,2266 ----
if (column < 0 || column >= clist->columns)
return;
! if (row == clist->rows - 1)
! clist_row = clist->row_list_end->data;
! else
! clist_row = (g_list_nth (clist->row_list, row))->data;
gdk_pixmap_ref (pixmap);
***************
*** 2282,2288 ****
if (column < 0 || column >= clist->columns)
return 0;
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (clist_row->cell[column].type != GTK_CELL_PIXMAP)
return 0;
--- 2294,2303 ----
if (column < 0 || column >= clist->columns)
return 0;
! if (row == clist->rows - 1)
! clist_row = clist->row_list_end->data;
! else
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (clist_row->cell[column].type != GTK_CELL_PIXMAP)
return 0;
***************
*** 2316,2322 ****
if (column < 0 || column >= clist->columns)
return;
! clist_row = (g_list_nth (clist->row_list, row))->data;
gdk_pixmap_ref (pixmap);
if (mask) gdk_pixmap_ref (mask);
--- 2331,2340 ----
if (column < 0 || column >= clist->columns)
return;
! if (row == clist->rows - 1)
! clist_row = clist->row_list_end->data;
! else
! clist_row = (g_list_nth (clist->row_list, row))->data;
gdk_pixmap_ref (pixmap);
if (mask) gdk_pixmap_ref (mask);
***************
*** 2350,2356 ****
if (column < 0 || column >= clist->columns)
return 0;
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (clist_row->cell[column].type != GTK_CELL_PIXTEXT)
return 0;
--- 2368,2377 ----
if (column < 0 || column >= clist->columns)
return 0;
! if (row == clist->rows - 1)
! clist_row = clist->row_list_end->data;
! else
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (clist_row->cell[column].type != GTK_CELL_PIXTEXT)
return 0;
***************
*** 2386,2392 ****
if (column < 0 || column >= clist->columns)
return;
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (clist->column[column].auto_resize &&
!GTK_CLIST_AUTO_RESIZE_BLOCKED(clist))
--- 2407,2416 ----
if (column < 0 || column >= clist->columns)
return;
! if (row == clist->rows - 1)
! clist_row = clist->row_list_end->data;
! else
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (clist->column[column].auto_resize &&
!GTK_CLIST_AUTO_RESIZE_BLOCKED(clist))
***************
*** 3009,3015 ****
if (row < 0 || row > (clist->rows - 1))
return;
! clist_row = (g_list_nth (clist->row_list, row))->data;
clist_row->data = data;
clist_row->destroy = destroy;
}
--- 3033,3042 ----
if (row < 0 || row > (clist->rows - 1))
return;
! if (row == clist->rows - 1)
! clist_row = clist->row_list_end->data;
! else
! clist_row = (g_list_nth (clist->row_list, row))->data;
clist_row->data = data;
clist_row->destroy = destroy;
}
***************
*** 3026,3032 ****
if (row < 0 || row > (clist->rows - 1))
return NULL;
! clist_row = (g_list_nth (clist->row_list, row))->data;
return clist_row->data;
}
--- 3053,3062 ----
if (row < 0 || row > (clist->rows - 1))
return NULL;
! if (row == clist->rows - 1)
! clist_row = clist->row_list_end->data;
! else
! clist_row = (g_list_nth (clist->row_list, row))->data;
return clist_row->data;
}
***************
*** 3135,3141 ****
if (row < 0 || row >= clist->rows)
return;
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (color)
{
--- 3165,3174 ----
if (row < 0 || row >= clist->rows)
return;
! if (row == clist->rows - 1)
! clist_row = clist->row_list_end->data;
! else
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (color)
{
***************
*** 3165,3171 ****
if (row < 0 || row >= clist->rows)
return;
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (color)
{
--- 3198,3207 ----
if (row < 0 || row >= clist->rows)
return;
! if (row == clist->rows - 1)
! clist_row = clist->row_list_end->data;
! else
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (color)
{
***************
*** 3206,3212 ****
if (column < 0 || column >= clist->columns)
return;
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (clist_row->cell[column].style == style)
return;
--- 3242,3251 ----
if (column < 0 || column >= clist->columns)
return;
! if (row == clist->rows - 1)
! clist_row = clist->row_list_end->data;
! else
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (clist_row->cell[column].style == style)
return;
***************
*** 3258,3264 ****
if (row < 0 || row >= clist->rows || column < 0 || column >= clist->columns)
return NULL;
! clist_row = (g_list_nth (clist->row_list, row))->data;
return clist_row->cell[column].style;
}
--- 3297,3306 ----
if (row < 0 || row >= clist->rows || column < 0 || column >= clist->columns)
return NULL;
! if (row == clist->rows - 1)
! clist_row = clist->row_list_end->data;
! else
! clist_row = (g_list_nth (clist->row_list, row))->data;
return clist_row->cell[column].style;
}
***************
*** 3279,3285 ****
if (row < 0 || row >= clist->rows)
return;
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (clist_row->style == style)
return;
--- 3321,3330 ----
if (row < 0 || row >= clist->rows)
return;
! if (row == clist->rows - 1)
! clist_row = clist->row_list_end->data;
! else
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (clist_row->style == style)
return;
***************
*** 3341,3347 ****
if (row < 0 || row >= clist->rows)
return NULL;
! clist_row = (g_list_nth (clist->row_list, row))->data;
return clist_row->style;
}
--- 3386,3395 ----
if (row < 0 || row >= clist->rows)
return NULL;
! if (row == clist->rows - 1)
! clist_row = clist->row_list_end->data;
! else
! clist_row = (g_list_nth (clist->row_list, row))->data;
return clist_row->style;
}
***************
*** 3368,3374 ****
if (row < 0 || row >= clist->rows)
return;
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (selectable == clist_row->selectable)
return;
--- 3416,3425 ----
if (row < 0 || row >= clist->rows)
return;
! if (row == clist->rows - 1)
! clist_row = clist->row_list_end->data;
! else
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (selectable == clist_row->selectable)
return;
***************
*** 3655,3661 ****
break;
}
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (clist_row->state != GTK_STATE_NORMAL || !clist_row->selectable)
return;
--- 3706,3715 ----
break;
}
! if (row == clist->rows - 1)
! clist_row = clist->row_list_end->data;
! else
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (clist_row->state != GTK_STATE_NORMAL || !clist_row->selectable)
return;
***************
*** 3690,3696 ****
if (row < 0 || row > (clist->rows - 1))
return;
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (clist_row->state == GTK_STATE_SELECTED)
{
--- 3744,3753 ----
if (row < 0 || row > (clist->rows - 1))
return;
! if (row == clist->rows - 1)
! clist_row = clist->row_list_end->data;
! else
! clist_row = (g_list_nth (clist->row_list, row))->data;
if (clist_row->state == GTK_STATE_SELECTED)
{
- References:
- [ethereal-dev] I hate GLists
- From: Guy Harris
- [ethereal-dev] I hate GLists
- Prev by Date: Re: [ethereal-dev] I hate GLists
- Next by Date: [ethereal-dev] Fun with performance
- Previous by thread: Re: [ethereal-dev] I hate GLists
- Next by thread: Re: [ethereal-dev] I hate GLists
- Index(es):





