aboutsummaryrefslogtreecommitdiffstats
path: root/epan/oids.c
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2016-04-07 13:05:27 -0700
committerGerald Combs <gerald@wireshark.org>2016-04-07 22:36:28 +0000
commit90e1232672446e79e75e5c6877310a49f23ae228 (patch)
tree35a198bf526976a0928cef81f98c9a15587de03f /epan/oids.c
parent71f2b6e1b4a7d011c55441decbc4a1ec27d9bd9c (diff)
Use faster string functions at startup.
Use wmem_strconcat and g_strconcat instead of wmem_strdup_printf and g_strdup_printf when we register various protocols. This shows a fairly significant speedup in the Visual Studio profiler. Change-Id: I98709329513daa66ad3665925dc69149c43df884 Reviewed-on: https://code.wireshark.org/review/14855 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/oids.c')
-rw-r--r--epan/oids.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/epan/oids.c b/epan/oids.c
index 9d14838fc8..5230c37c8b 100644
--- a/epan/oids.c
+++ b/epan/oids.c
@@ -437,7 +437,7 @@ static inline oid_kind_t smikind(SmiNode* sN, oid_key_t** key_p) {
oid1 = smiRenderOID(sN->oidlen, sN->oid, SMI_RENDER_QUALIFIED);
oid2 = smiRenderOID(elNode->oidlen, elNode->oid, SMI_RENDER_NAME);
- k->name = g_strdup_printf("%s.%s", oid1, oid2);
+ k->name = g_strconcat(oid1, ".", oid2, NULL);
smi_free (oid1);
smi_free (oid2);
@@ -696,8 +696,8 @@ static void register_mibs(void) {
bits->data[n].hfid = -1;
bits->data[n].offset = smiEnum->value.value.integer32 / 8;
- hf2.hfinfo.name = g_strdup_printf("%s:%s",oid_data->name,smiEnum->name);
- hf2.hfinfo.abbrev = g_strdup_printf("%s.%s",base,ext);
+ hf2.hfinfo.name = g_strconcat("%s:%s",oid_data->name, ":", smiEnum->name, NULL);
+ hf2.hfinfo.abbrev = g_strconcat(base, ".", ext, NULL);
g_free(base);
g_free(ext);
@@ -872,7 +872,16 @@ char* rel_oid_subid2string(wmem_allocator_t *scope, guint32* subids, guint len,
*w++ = '.';
do {
+#ifdef _WIN32
+ /*
+ * GLib appears to use gnulib's snprintf on Windows, which is
+ * slow. MSDN says that _snprintf can return -1, but that
+ * shouldn't be possible here.
+ */
+ w += _snprintf(w,12,"%u.",*subids++);
+#else
w += g_snprintf(w,12,"%u.",*subids++);
+#endif
} while(--len);
if (w!=s) *(w-1) = '\0'; else *(s) = '\0';
@@ -1212,7 +1221,7 @@ gchar *oid_resolved(wmem_allocator_t *scope, guint32 num_subids, guint32* subids
*str1 = oid_subid2string(NULL, subids,matched),
*str2 = oid_subid2string(NULL, &(subids[matched]),left);
- ret = wmem_strdup_printf(scope, "%s.%s", oid->name ? oid->name : str1, str2);
+ ret = wmem_strconcat(scope, oid->name ? oid->name : str1, ".", str2, NULL);
wmem_free(NULL, str1);
wmem_free(NULL, str2);
return ret;