summaryrefslogtreecommitdiff
path: root/epan/column-utils.c
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2015-08-26 17:14:39 -0700
committerGerald Combs <gerald@wireshark.org>2015-08-28 02:54:20 +0000
commitf19a173a8409ff62a77939e66b4a97d26cc5c149 (patch)
tree9530c97f8ebafd0d0a791cf1f08aa5f4e90fcdb7 /epan/column-utils.c
parent01fb470acd71528bede068727b7614ae6f534c4f (diff)
downloadwireshark-f19a173a8409ff62a77939e66b4a97d26cc5c149.tar.gz
Speed up column sorting.
The GTK+ UI sequentially dissects and caches column strings for all rows before sorting a column. Do the same in the Qt UI, which can improve performance considerably. Don't colorize packets when sorting in the Qt UI unless it's necessary. When sorting in the Qt UI, let the user cancel the initial packet dissection. Note that we'll need to replace std::sort in order to cancel out of sorting. Use a pre-allocated and pre-compiled GRexex when we prime columns. Note that we probably shouldn't parse a regular expression there. Cache the last result of proto_registrar_get_byname. Note performance hot spots elsewhere in the code. To do: GeoIP in packet-ip.c is pretty slow. Bug: 11467 Change-Id: Ib34038fee08ef0319261faeffc4eca01e52f4bd3 Reviewed-on: https://code.wireshark.org/review/10275 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'epan/column-utils.c')
-rw-r--r--epan/column-utils.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/epan/column-utils.c b/epan/column-utils.c
index 4dd0336623..d9e8b1bc0b 100644
--- a/epan/column-utils.c
+++ b/epan/column-utils.c
@@ -63,6 +63,8 @@ col_setup(column_info *cinfo, const gint num_cols)
cinfo->col_first[i] = -1;
cinfo->col_last[i] = -1;
}
+ cinfo->prime_regex = g_regex_new(" *([^ \\|]+) *(?:(?:\\|\\|)|(?:or))? *",
+ G_REGEX_ANCHORED, G_REGEX_MATCH_ANCHORED, NULL);
}
static void
@@ -113,6 +115,7 @@ col_cleanup(column_info *cinfo)
*/
g_free((gchar **)cinfo->col_expr.col_expr);
g_free(cinfo->col_expr.col_expr_val);
+ g_regex_unref(cinfo->prime_regex);
}
/* Initialize the data structures for constructing column data. */
@@ -336,8 +339,9 @@ col_custom_prime_edt(epan_dissect_t *edt, column_info *cinfo)
gchar **fields;
guint i_field = 0;
- fields = g_regex_split_simple(" *([^ \\|]+) *(?:(?:\\|\\|)|(?:or))? *",
- col_item->col_custom_field, G_REGEX_ANCHORED, G_REGEX_MATCH_ANCHORED);
+ /* Not using a GRegex here would improve performance. */
+ fields = g_regex_split(cinfo->prime_regex, col_item->col_custom_field,
+ G_REGEX_MATCH_ANCHORED);
for (i_field =0; i_field < g_strv_length(fields); i_field += 1) {
if (fields[i_field] && *fields[i_field]) {