Skip to content

Commit

Permalink
Optimized finding current row from cfile.current_frame.
Browse files Browse the repository at this point in the history
svn path=/trunk/; revision=26804
  • Loading branch information
stigbjorlykke committed Nov 18, 2008
1 parent bfd1d4e commit 5498ec1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 30 deletions.
1 change: 1 addition & 0 deletions cfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ typedef struct _capture_file {
frame_data *last_displayed; /* Last frame displayed */
column_info cinfo; /* Column formatting information */
frame_data *current_frame; /* Frame data for current frame */
gint current_row; /* Row number for current frame */
epan_dissect_t *edt; /* Protocol dissection for currently selected packet */
field_info *finfo_selected; /* Field info for currently selected field */
struct ph_stats_s* pstats; /* accumulated stats (reset on redisplay in GUI)*/
Expand Down
5 changes: 5 additions & 0 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ cf_reset_state(capture_file *cf)

/* No frame selected, no field in that frame selected. */
cf->current_frame = NULL;
cf->current_row = 0;
cf->finfo_selected = NULL;

/* Clear the packet list. */
Expand Down Expand Up @@ -566,6 +567,8 @@ cf_read(capture_file *cf)
cf->lnk_t = wtap_file_encap(cf->wth);

cf->current_frame = cf->first_displayed;
cf->current_row = 0;

packet_list_thaw();

cf_callback_invoke(cf_cb_file_read_finished, cf);
Expand Down Expand Up @@ -3342,6 +3345,7 @@ cf_select_packet(capture_file *cf, int row)

/* Record that this frame is the current frame. */
cf->current_frame = fdata;
cf->current_row = row;

/* Create the logical protocol tree. */
if (cf->edt != NULL) {
Expand Down Expand Up @@ -3371,6 +3375,7 @@ cf_unselect_packet(capture_file *cf)

/* No packet is selected. */
cf->current_frame = NULL;
cf->current_row = 0;

cf_callback_invoke(cf_cb_packet_unselected, cf);

Expand Down
8 changes: 2 additions & 6 deletions gtk/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,8 @@ static void reftime_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_
}

if (cfile.current_frame) {
/* XXX hum, should better have a "cfile->current_row" here ... */
set_frame_reftime(!cfile.current_frame->flags.ref_time,
cfile.current_frame,
packet_list_find_row_from_data(cfile.current_frame));
cfile.current_frame, cfile.current_row);
}
}

Expand All @@ -548,10 +546,8 @@ reftime_frame_cb(GtkWidget *w _U_, gpointer data _U_, REFTIME_ACTION_E action)
simple_dialog_primary_start(), simple_dialog_primary_end());
simple_dialog_set_cb(reftime_dialog, reftime_answered_cb, NULL);
} else {
/* XXX hum, should better have a "cfile->current_row" here ... */
set_frame_reftime(!cfile.current_frame->flags.ref_time,
cfile.current_frame,
packet_list_find_row_from_data(cfile.current_frame));
cfile.current_frame, cfile.current_row);
}
}
break;
Expand Down
40 changes: 16 additions & 24 deletions gtk/main_packet_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,7 @@ packet_list_select_cb(GtkWidget *w _U_, gint row, gint col _U_, GdkEventButton *
frame_data *fdata;

/* Check if already selected */
if (cfile.current_frame &&
(gtk_clist_find_row_from_data(GTK_CLIST(packet_list), cfile.current_frame) == row))
if (cfile.current_frame && cfile.current_row == row)
return;

/* Remove the hex display tabbed pages */
Expand Down Expand Up @@ -330,11 +329,8 @@ static void mark_frames_ready(void) {

void packet_list_mark_frame_cb(GtkWidget *w _U_, gpointer data _U_) {
if (cfile.current_frame) {
/* XXX hum, should better have a "cfile->current_row" here ... */
set_frame_mark(!cfile.current_frame->flags.marked,
cfile.current_frame,
gtk_clist_find_row_from_data(GTK_CLIST(packet_list),
cfile.current_frame));
cfile.current_frame, cfile.current_row);
mark_frames_ready();
}
}
Expand Down Expand Up @@ -934,36 +930,32 @@ packet_list_get_sort_column(void)

void packet_list_copy_summary_cb(GtkWidget * w _U_, gpointer data _U_, copy_summary_type copy_type)
{
gint row;
gint col;
gchar* celltext = NULL;
GString* text;

if(CS_CSV == copy_type) {
text = g_string_new("\"");
} else {
text = g_string_new("");
}
if(CS_CSV == copy_type) {
text = g_string_new("\"");
} else {
text = g_string_new("");
}

if (cfile.current_frame) {
/* XXX hum, should better have a "cfile->current_row" here ... */
row = gtk_clist_find_row_from_data(GTK_CLIST(packet_list),
cfile.current_frame);
for(col = 0; col < cfile.cinfo.num_cols; ++col) {
if(col != 0) {
if(CS_CSV == copy_type) {
g_string_append(text,"\",\"");
} else {
g_string_append_c(text, '\t');
}
if(CS_CSV == copy_type) {
g_string_append(text,"\",\"");
} else {
g_string_append_c(text, '\t');
}
}
if(0 != gtk_clist_get_text(GTK_CLIST(packet_list),row,col,&celltext)) {
if(0 != gtk_clist_get_text(GTK_CLIST(packet_list),cfile.current_row,col,&celltext)) {
g_string_append(text,celltext);
}
}
if(CS_CSV == copy_type) {
g_string_append_c(text,'"');
}
if(CS_CSV == copy_type) {
g_string_append_c(text,'"');
}
copy_to_clipboard(text);
}
g_string_free(text,TRUE);
Expand Down

0 comments on commit 5498ec1

Please sign in to comment.