From 696a79707b4ec36f7f1b6e8cfdcd07871ac85a7e Mon Sep 17 00:00:00 2001 From: Jakub Zawadzki Date: Thu, 25 Jul 2013 17:19:17 +0000 Subject: Optimize proto_item_append_string() - When old string empty just pass new one (like: frame.protocols) - if not, use ep_strconcat() svn path=/trunk/; revision=50890 --- epan/proto.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'epan') diff --git a/epan/proto.c b/epan/proto.c index 1d2541d452..ae5d632c70 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -2558,7 +2558,7 @@ proto_item_append_string(proto_item *pi, const char *str) { field_info *fi; header_field_info *hfinfo; - gchar *old_str, *new_str; + const gchar *old_str, *new_str; if (!pi) return; @@ -2575,8 +2575,11 @@ proto_item_append_string(proto_item *pi, const char *str) } DISSECTOR_ASSERT(hfinfo->type == FT_STRING || hfinfo->type == FT_STRINGZ); old_str = (guint8 *)fvalue_get(&fi->value); - new_str = ep_strdup_printf("%s%s", old_str, str); - fvalue_set(&fi->value, new_str, FALSE); + if (old_str && old_str[0]) + new_str = ep_strconcat(old_str, str, NULL); + else + new_str = str; + fvalue_set(&fi->value, (gpointer) new_str, FALSE); } /* Set the FT_STRING value */ -- cgit v1.2.1