From 86a8ad1dcd6af20f8982e39cc70f3debaa2a8352 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 10 Aug 1999 04:13:37 +0000 Subject: Building a GList by adding elements to the end with "g_list_append()" is N^2 in the ultimate size of the list (as "g_list_append()" is linear in the size of the list, at least when used in the way the GLib documentation says to use it); instead, maintain our own linked list of "frame_data" structures for all packets read, including a pointer to the last element. "gtk_clist_set_row_data()" is linear in the row number, so if it's used to attach a pointer to the "frame_data" structure for a packet to the packet list GtkClist row for each packet, that's also N^2 in the number of packets in that packet list; instead, store the row number in the "frame_data" structure, and find the packet for a given row by scanning the list for it (we were already scanning the list linearly to find that packet's index in the list of all packets; that's only done when a packet's selected, so it's not *too* bad, but it might be nice to avoid having to do that scan). svn path=/trunk/; revision=457 --- summary.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'summary.c') diff --git a/summary.c b/summary.c index e6d9418408..fd02eb17e1 100644 --- a/summary.c +++ b/summary.c @@ -1,7 +1,7 @@ /* summary.c * Routines for capture file summary window * - * $Id: summary.c,v 1.7 1999/08/02 02:04:27 guy Exp $ + * $Id: summary.c,v 1.8 1999/08/10 04:13:36 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -128,10 +128,10 @@ summary_prep_cb(GtkWidget *w, gpointer d) { guint32 traffic_bytes, i; double seconds; - GList *cur_glist; + frame_data *cur_glist; /* initialize the tally */ - first_frame = (frame_data *)(cf.plist->data); + first_frame = cf.plist; st = (summary_tally *)g_malloc(sizeof(summary_tally)); st->start_time = secs_usecs(first_frame->abs_secs,first_frame->abs_usecs) ; @@ -142,12 +142,10 @@ summary_prep_cb(GtkWidget *w, gpointer d) { cur_glist = cf.plist; for (i = 0; i < cf.count; i++){ - cur_frame = (frame_data *)cur_glist->data; + cur_frame = cur_glist; tally_frame_data(cur_frame, st); cur_glist = cur_glist->next; - } - - /* g_list_foreach(cf.plist_first, (GFunc)tally_frame_data, st); */ + } /* traffic_bytes will be computed here */ traffic_bytes = st->bytes; -- cgit v1.2.1