forked from osmocom/wireshark
Apply yet another set of the optimization patches:
- Don't call tree_view_select on first button click event, it's already done by the tree widget. - Factorize slow gtk_text_buffer_insert_with_tags_by_name() calls svn path=/trunk/; revision=23477
This commit is contained in:
parent
794afa7963
commit
f6d282b6cd
|
@ -2131,7 +2131,7 @@ popup_menu_handler(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we are on tree_view object */
|
/* Check if we are on tree_view object */
|
||||||
if (widget == tree_view) {
|
if (widget == tree_view && ((GdkEventButton *)event)->button != 1) {
|
||||||
tree_view_select(widget, (GdkEventButton *) event);
|
tree_view_select(widget, (GdkEventButton *) event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -324,7 +324,8 @@ toggle_tree(GtkCTree *ctree, GdkEventKey *event, gpointer user_data _U_)
|
||||||
3 characters per byte of hex dump,
|
3 characters per byte of hex dump,
|
||||||
2 blanks separating hex from ASCII,
|
2 blanks separating hex from ASCII,
|
||||||
1 character per byte of ASCII dump */
|
1 character per byte of ASCII dump */
|
||||||
#define MAX_LINE_LEN (MAX_OFFSET_LEN + 2 + DATA_DUMP_LEN)
|
#define MAX_LINES 100
|
||||||
|
#define MAX_LINE_LEN (MAX_LINES *(MAX_OFFSET_LEN + 2 + DATA_DUMP_LEN))
|
||||||
/* number of characters per line;
|
/* number of characters per line;
|
||||||
offset, 2 blanks separating offset
|
offset, 2 blanks separating offset
|
||||||
from data dump, data dump */
|
from data dump, data dump */
|
||||||
|
@ -1172,8 +1173,6 @@ packet_hex_print_common(GtkWidget *bv, const guint8 *pd, int len, int bstart,
|
||||||
GtkTextBuffer *buf = gtk_text_view_get_buffer(bv_text_view);
|
GtkTextBuffer *buf = gtk_text_view_get_buffer(bv_text_view);
|
||||||
GtkTextIter iter;
|
GtkTextIter iter;
|
||||||
const char *revstyle;
|
const char *revstyle;
|
||||||
gchar *convline;
|
|
||||||
gsize newsize;
|
|
||||||
GtkTextMark *mark = NULL;
|
GtkTextMark *mark = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1200,6 +1199,8 @@ packet_hex_print_common(GtkWidget *bv, const guint8 *pd, int len, int bstart,
|
||||||
#else
|
#else
|
||||||
gtk_text_buffer_set_text(buf, "", 0);
|
gtk_text_buffer_set_text(buf, "", 0);
|
||||||
gtk_text_buffer_get_start_iter(buf, &iter);
|
gtk_text_buffer_get_start_iter(buf, &iter);
|
||||||
|
g_object_ref(buf);
|
||||||
|
gtk_text_view_set_buffer( bv_text_view, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1232,6 +1233,7 @@ packet_hex_print_common(GtkWidget *bv, const guint8 *pd, int len, int bstart,
|
||||||
progbar_stop_flag = FALSE;
|
progbar_stop_flag = FALSE;
|
||||||
g_get_current_time(&progbar_start_time);
|
g_get_current_time(&progbar_start_time);
|
||||||
|
|
||||||
|
cur = 0;
|
||||||
while (i < len) {
|
while (i < len) {
|
||||||
/* Create the progress bar if necessary.
|
/* Create the progress bar if necessary.
|
||||||
We check on every iteration of the loop, so that it takes no
|
We check on every iteration of the loop, so that it takes no
|
||||||
|
@ -1275,7 +1277,6 @@ packet_hex_print_common(GtkWidget *bv, const guint8 *pd, int len, int bstart,
|
||||||
|
|
||||||
/* Print the line number */
|
/* Print the line number */
|
||||||
j = use_digits;
|
j = use_digits;
|
||||||
cur = 0;
|
|
||||||
do {
|
do {
|
||||||
j--;
|
j--;
|
||||||
c = (i >> (j*4)) & 0xF;
|
c = (i >> (j*4)) & 0xF;
|
||||||
|
@ -1283,12 +1284,11 @@ packet_hex_print_common(GtkWidget *bv, const guint8 *pd, int len, int bstart,
|
||||||
} while (j != 0);
|
} while (j != 0);
|
||||||
line[cur++] = ' ';
|
line[cur++] = ' ';
|
||||||
line[cur++] = ' ';
|
line[cur++] = ' ';
|
||||||
line[cur] = '\0';
|
|
||||||
|
|
||||||
/* Display with inverse video ? */
|
/* Display with inverse video ? */
|
||||||
#if GTK_MAJOR_VERSION < 2
|
#if GTK_MAJOR_VERSION < 2
|
||||||
if (prefs.gui_hex_dump_highlight_style) {
|
if (prefs.gui_hex_dump_highlight_style) {
|
||||||
gtk_text_insert(bv_text, user_font_get_regular(), &BLACK, &WHITE, line, -1);
|
gtk_text_insert(bv_text, user_font_get_regular(), &BLACK, &WHITE, line, cur);
|
||||||
/* Do we start in reverse? */
|
/* Do we start in reverse? */
|
||||||
reverse = (i >= bstart && i < bend) || (i >= astart && i < aend);
|
reverse = (i >= bstart && i < bend) || (i >= astart && i < aend);
|
||||||
fg = reverse ? &WHITE : &BLACK;
|
fg = reverse ? &WHITE : &BLACK;
|
||||||
|
@ -1384,14 +1384,12 @@ packet_hex_print_common(GtkWidget *bv, const guint8 *pd, int len, int bstart,
|
||||||
reverse = newreverse;
|
reverse = newreverse;
|
||||||
}
|
}
|
||||||
/* Print remaining part of line */
|
/* Print remaining part of line */
|
||||||
|
line[cur++] = '\n';
|
||||||
gtk_text_insert(bv_text, user_font_get_regular(), fg, bg, line, cur);
|
gtk_text_insert(bv_text, user_font_get_regular(), fg, bg, line, cur);
|
||||||
cur = 0;
|
cur = 0;
|
||||||
line[cur++] = '\n';
|
|
||||||
line[cur] = '\0';
|
|
||||||
gtk_text_insert(bv_text, user_font_get_regular(), &BLACK, &WHITE, line, -1);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
gtk_text_insert(bv_text, user_font_get_regular(), NULL, NULL, line, -1);
|
gtk_text_insert(bv_text, user_font_get_regular(), NULL, NULL, line, cur);
|
||||||
/* Do we start in bold? */
|
/* Do we start in bold? */
|
||||||
cur_font = ((i >= bstart && i < bend) || (i >= astart && i < aend)) ? user_font_get_bold() : user_font_get_regular();
|
cur_font = ((i >= bstart && i < bend) || (i >= astart && i < aend)) ? user_font_get_bold() : user_font_get_regular();
|
||||||
j = i;
|
j = i;
|
||||||
|
@ -1451,8 +1449,8 @@ packet_hex_print_common(GtkWidget *bv, const guint8 *pd, int len, int bstart,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
line[cur++] = '\n';
|
line[cur++] = '\n';
|
||||||
line[cur] = '\0';
|
gtk_text_insert(bv_text, cur_font, NULL, NULL, line, cur);
|
||||||
gtk_text_insert(bv_text, cur_font, NULL, NULL, line, -1);
|
cur = 0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (prefs.gui_hex_dump_highlight_style)
|
if (prefs.gui_hex_dump_highlight_style)
|
||||||
|
@ -1460,13 +1458,15 @@ packet_hex_print_common(GtkWidget *bv, const guint8 *pd, int len, int bstart,
|
||||||
else
|
else
|
||||||
revstyle = "bold";
|
revstyle = "bold";
|
||||||
|
|
||||||
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, line, -1,
|
|
||||||
"plain", NULL);
|
|
||||||
/* Do we start in reverse? */
|
/* Do we start in reverse? */
|
||||||
reverse = (i >= bstart && i < bend) || (i >= astart && i < aend);
|
reverse = (i >= bstart && i < bend) || (i >= astart && i < aend);
|
||||||
j = i;
|
j = i;
|
||||||
k = i + BYTE_VIEW_WIDTH;
|
k = i + BYTE_VIEW_WIDTH;
|
||||||
cur = 0;
|
if (reverse) {
|
||||||
|
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, line, cur,
|
||||||
|
"plain", NULL);
|
||||||
|
cur = 0;
|
||||||
|
}
|
||||||
/* Print the hex bit */
|
/* Print the hex bit */
|
||||||
while (i < k) {
|
while (i < k) {
|
||||||
if (i < len) {
|
if (i < len) {
|
||||||
|
@ -1500,21 +1500,26 @@ packet_hex_print_common(GtkWidget *bv, const guint8 *pd, int len, int bstart,
|
||||||
}
|
}
|
||||||
reverse = newreverse;
|
reverse = newreverse;
|
||||||
}
|
}
|
||||||
/* Print remaining part of line */
|
if (reverse) {
|
||||||
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, line, cur,
|
/* Print remaining part of line */
|
||||||
reverse ? revstyle : "plain",
|
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, line, cur,
|
||||||
NULL);
|
revstyle, NULL);
|
||||||
cur = 0;
|
cur = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Print some space at the end of the line */
|
/* Print some space at the end of the line */
|
||||||
line[cur++] = ' '; line[cur++] = ' '; line[cur++] = ' ';
|
line[cur++] = ' '; line[cur++] = ' '; line[cur++] = ' ';
|
||||||
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, line, cur,
|
|
||||||
"plain", NULL);
|
|
||||||
cur = 0;
|
|
||||||
|
|
||||||
/* Print the ASCII bit */
|
/* Print the ASCII bit */
|
||||||
i = j;
|
i = j;
|
||||||
/* Do we start in reverse? */
|
/* Do we start in reverse? */
|
||||||
reverse = (i >= bstart && i < bend) || (i >= astart && i < aend);
|
reverse = (i >= bstart && i < bend) || (i >= astart && i < aend);
|
||||||
|
if (reverse) {
|
||||||
|
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, line, cur,
|
||||||
|
"plain",NULL);
|
||||||
|
cur = 0;
|
||||||
|
}
|
||||||
|
|
||||||
while (i < k) {
|
while (i < k) {
|
||||||
if (i < len) {
|
if (i < len) {
|
||||||
if (encoding == CHAR_ASCII) {
|
if (encoding == CHAR_ASCII) {
|
||||||
|
@ -1534,10 +1539,9 @@ packet_hex_print_common(GtkWidget *bv, const guint8 *pd, int len, int bstart,
|
||||||
newreverse = (i >= bstart && i < bend) || (i >= astart && i < aend);
|
newreverse = (i >= bstart && i < bend) || (i >= astart && i < aend);
|
||||||
/* Have we gone from reverse to plain? */
|
/* Have we gone from reverse to plain? */
|
||||||
if (reverse && (reverse != newreverse)) {
|
if (reverse && (reverse != newreverse)) {
|
||||||
convline = g_locale_to_utf8(line, cur, NULL, &newsize, NULL);
|
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, line, cur,
|
||||||
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, convline, newsize,
|
|
||||||
revstyle, NULL);
|
revstyle, NULL);
|
||||||
g_free( (gpointer) convline);
|
|
||||||
cur = 0;
|
cur = 0;
|
||||||
}
|
}
|
||||||
if (i < k) {
|
if (i < k) {
|
||||||
|
@ -1548,24 +1552,24 @@ packet_hex_print_common(GtkWidget *bv, const guint8 *pd, int len, int bstart,
|
||||||
}
|
}
|
||||||
/* Have we gone from plain to reversed? */
|
/* Have we gone from plain to reversed? */
|
||||||
if (!reverse && (reverse != newreverse)) {
|
if (!reverse && (reverse != newreverse)) {
|
||||||
convline = g_locale_to_utf8(line, cur, NULL, &newsize, NULL);
|
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, line, cur,
|
||||||
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, convline, newsize,
|
|
||||||
"plain", NULL);
|
"plain", NULL);
|
||||||
g_free( (gpointer) convline);
|
|
||||||
cur = 0;
|
cur = 0;
|
||||||
}
|
}
|
||||||
reverse = newreverse;
|
reverse = newreverse;
|
||||||
}
|
}
|
||||||
/* Print remaining part of line */
|
/* Print remaining part of line */
|
||||||
convline = g_locale_to_utf8(line, cur, NULL, &newsize, NULL);
|
if (reverse) {
|
||||||
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, convline, newsize,
|
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, line, cur,
|
||||||
reverse ? revstyle : "plain",
|
revstyle, NULL);
|
||||||
NULL);
|
cur = 0;
|
||||||
g_free( (gpointer) convline);
|
}
|
||||||
cur = 0;
|
|
||||||
line[cur++] = '\n';
|
line[cur++] = '\n';
|
||||||
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, line, cur,
|
if (cur >= MAX_LINE_LEN) {
|
||||||
|
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, line, cur,
|
||||||
"plain", NULL);
|
"plain", NULL);
|
||||||
|
cur = 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1588,10 +1592,17 @@ packet_hex_print_common(GtkWidget *bv, const guint8 *pd, int len, int bstart,
|
||||||
gtk_adjustment_set_value(bv_text->vadj, scrollval);
|
gtk_adjustment_set_value(bv_text->vadj, scrollval);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
if (cur) {
|
||||||
|
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, line, cur,
|
||||||
|
"plain", NULL);
|
||||||
|
}
|
||||||
|
gtk_text_view_set_buffer( bv_text_view, buf);
|
||||||
|
|
||||||
if (mark) {
|
if (mark) {
|
||||||
gtk_text_view_scroll_to_mark(bv_text_view, mark, 0.0, TRUE, 1.0, 0.0);
|
gtk_text_view_scroll_to_mark(bv_text_view, mark, 0.0, TRUE, 1.0, 0.0);
|
||||||
gtk_text_buffer_delete_mark(buf, mark);
|
gtk_text_buffer_delete_mark(buf, mark);
|
||||||
}
|
}
|
||||||
|
g_object_unref(buf);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue