diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2009-07-12 10:19:13 +0000 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2009-07-12 10:19:13 +0000 |
commit | 27572c22f4c47b845c90700f46e27d239515531c (patch) | |
tree | 8a20bb03d20a569e22078dd31657e0eaa9bd66e3 /epan | |
parent | 052a2b965a424465fb87c83a5f2009b35471be8b (diff) |
From Kovarththanan Rajaratnam via bug 3702:
This patch optimizes the data source name processing in add_new_data_source()
by delaying it. We now simply store the constant string and lazily compute the
name when needed. This gives a performance boost because we only need the name
if we have multiple data sources.
svn path=/trunk/; revision=29066
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-dcerpc-eventlog.c | 2 | ||||
-rw-r--r-- | epan/frame_data.h | 3 | ||||
-rw-r--r-- | epan/libwireshark.def | 1 | ||||
-rw-r--r-- | epan/packet.c | 19 | ||||
-rw-r--r-- | epan/packet.h | 5 |
5 files changed, 22 insertions, 8 deletions
diff --git a/epan/dissectors/packet-dcerpc-eventlog.c b/epan/dissectors/packet-dcerpc-eventlog.c index 817b32e3d5..0a14d24258 100644 --- a/epan/dissectors/packet-dcerpc-eventlog.c +++ b/epan/dissectors/packet-dcerpc-eventlog.c @@ -1586,7 +1586,7 @@ eventlog_dissect_element_ReadEventLogW_handle_(tvbuff_t *tvb _U_, int offset _U_ static int eventlog_dissect_element_ReadEventLogW_flags(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_) { - offset = PIDL_dissect_uint32(tvb, offset, pinfo, tree, drep, hf_eventlog_eventlog_ReadEventLogW_flags, 0); + offset = eventlog_dissect_bitmap_eventlogReadFlags(tvb, offset, pinfo, tree, drep, hf_eventlog_eventlog_ReadEventLogW_flags, 0); return offset; } diff --git a/epan/frame_data.h b/epan/frame_data.h index f8332803e9..197cf332bf 100644 --- a/epan/frame_data.h +++ b/epan/frame_data.h @@ -67,7 +67,8 @@ typedef struct _frame_data { */ typedef struct { tvbuff_t *tvb; - char *name; + gboolean name_initialized; + const char *name; } data_source; /* Utility routines used by packet*.c */ diff --git a/epan/libwireshark.def b/epan/libwireshark.def index f3456b8088..462350bf28 100644 --- a/epan/libwireshark.def +++ b/epan/libwireshark.def @@ -485,6 +485,7 @@ get_column_title get_column_width_string get_datafile_dir get_datafile_path +get_data_source_name get_dirname get_dissector_table_selector_type get_dissector_table_ui_name diff --git a/epan/packet.c b/epan/packet.c index 56742448d9..39eefb0b07 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -197,15 +197,22 @@ add_new_data_source(packet_info *pinfo, tvbuff_t *tvb, const char *name) src = ep_alloc(sizeof (data_source)); src->tvb = tvb; - /* - * XXX - if we require this argument to be a string constant, - * we don't need to allocate a buffer for a copy and make a - * copy, and wouldn't need to free the buffer, either. - */ - src->name = ep_strdup_printf("%s (%u bytes)", name, tvb_length(tvb)); + src->name_initialized = FALSE; + src->name = name; pinfo->data_src = g_slist_append(pinfo->data_src, src); } +const char* +get_data_source_name(data_source *src) +{ + if (!src->name_initialized) { + src->name = ep_strdup_printf("%s (%u bytes)", src->name, tvb_length(src->tvb)); + src->name_initialized = TRUE; + } + + return src->name; +} + /* * Free up a frame's list of data sources. */ diff --git a/epan/packet.h b/epan/packet.h index 9f35f4d234..5725b58dd5 100644 --- a/epan/packet.h +++ b/epan/packet.h @@ -384,6 +384,11 @@ extern void add_new_data_source(packet_info *pinfo, tvbuff_t *tvb, const char *name); /* + * Return the data source name. + */ +extern const char* get_data_source_name(data_source *src); + +/* * Free up a frame's list of data sources. */ extern void free_data_sources(packet_info *pinfo); |