diff options
author | Gerald Combs <gerald@wireshark.org> | 2016-07-13 11:06:52 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2016-07-13 22:23:05 +0000 |
commit | 998ab7f7e5fba959b5451c8ac95a1a87acfbd9b4 (patch) | |
tree | aa577552433c1d3f75f6cd3f007cfc94f12f2e38 /epan/column-utils.c | |
parent | 1bd438ba5236d81afeb2190f637e85eb6a12beaf (diff) | |
download | wireshark-998ab7f7e5fba959b5451c8ac95a1a87acfbd9b4.tar.gz wireshark-998ab7f7e5fba959b5451c8ac95a1a87acfbd9b4.tar.bz2 wireshark-998ab7f7e5fba959b5451c8ac95a1a87acfbd9b4.zip |
Speed up col_append_ports on Windows.
Fill in our port information using StringCchPrintf on Windows instead
of g_snprintf. Loading a large-ish test capture here under the VS 2013
profiler showed that we spent 620 samples in col_append_ports. Switching
from g_snprintf to StringCchPrintf reduced that to six samples.
Inline col_snprint_port while we're here.
Change-Id: I955e5baa66ebb9cc950fc0eb1682d3c015c7a55a
Reviewed-on: https://code.wireshark.org/review/16416
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.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/epan/column-utils.c b/epan/column-utils.c index bbff48a21e..a3bfe87ecc 100644 --- a/epan/column-utils.c +++ b/epan/column-utils.c @@ -25,6 +25,10 @@ #include <string.h> #include <time.h> +#ifdef _WIN32 +#include <strsafe.h> +#endif + #include "column-utils.h" #include "timestamp.h" #include "to_str.h" @@ -434,19 +438,29 @@ col_append_str_uint(column_info *cinfo, const gint col, const gchar *abbrev, gui col_append_lstr(cinfo, col, sep ? sep : "", abbrev, "=", buf, COL_ADD_LSTR_TERMINATOR); } -static int +static inline void col_snprint_port(gchar *buf, gulong buf_siz, port_type typ, guint16 val) { const char *str; - int n; if (gbl_resolv_flags.transport_name && (str = try_serv_name_lookup(typ, val)) != NULL) { - n = g_snprintf(buf, buf_siz, "%s(%"G_GUINT16_FORMAT")", str, val); +/* + * I'm not sure what GLib is doing on Windows, but according to the VS 2013 + * profiler StringCchPrintf does it in 100x fewer samples. + */ +#ifdef _WIN32 + StringCchPrintfA(buf, buf_siz, "%s(%hu)", str, val); +#else + g_snprintf(buf, buf_siz, "%s(%"G_GUINT16_FORMAT")", str, val); +#endif } else { - n = g_snprintf(buf, buf_siz, "%"G_GUINT16_FORMAT, val); +#ifdef _WIN32 + StringCchPrintfA(buf, buf_siz, "%hu", val); +#else + g_snprintf(buf, buf_siz, "%"G_GUINT16_FORMAT, val); +#endif } - return n; } void |