diff options
author | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 1999-08-10 04:13:37 +0000 |
---|---|---|
committer | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 1999-08-10 04:13:37 +0000 |
commit | f4e1e6a41410ae372f2565eda305e7b3d1aa91ee (patch) | |
tree | c8fb7d5a71eab0ef89a425465a8e37b9fb9ccb90 /summary.c | |
parent | aa90289afc2f8e8717947a0c42f1a281c1bf1719 (diff) |
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).
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@457 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'summary.c')
-rw-r--r-- | summary.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -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 <gerald@zing.org> @@ -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; |