From f4b0abc7296bbb431e64e31f85b24c29196c2ae4 Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Fri, 16 Dec 2016 20:06:11 -0500 Subject: Dissectors don't need a journey of self discovery. They already know who they are when they register themselves. Saving the handle then to avoid finding it later. Not sure if this will increase unnecessary register_dissector functions (instead of using create_dissector_handle in proto_reg_handoff function) when other dissectors copy/paste, but it should make startup time a few microseconds better. Change-Id: I3839be791b32b84887ac51a6a65fb5733e9f1f43 Reviewed-on: https://code.wireshark.org/review/19481 Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- epan/dissectors/packet-jxta.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'epan/dissectors/packet-jxta.c') diff --git a/epan/dissectors/packet-jxta.c b/epan/dissectors/packet-jxta.c index cf3681fad0..19b1d4bea4 100644 --- a/epan/dissectors/packet-jxta.c +++ b/epan/dissectors/packet-jxta.c @@ -171,6 +171,8 @@ static int uri_address_type = -1; static gboolean gDESEGMENT = TRUE; static gboolean gMSG_MEDIA = TRUE; +static dissector_handle_t jxta_udp_handle; + /** * Stream Conversation data **/ @@ -470,9 +472,7 @@ static int dissect_jxta_udp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tr conversation_t *conversation = find_or_create_conversation(pinfo); - DISSECTOR_ASSERT(find_dissector("jxta.udp")); - - conversation_set_dissector(conversation, find_dissector("jxta.udp")); + conversation_set_dissector(conversation, jxta_udp_handle); while (TRUE) { tvbuff_t *jxta_message_framing_tvb; @@ -2344,8 +2344,8 @@ void proto_register_jxta(void) proto_message_jxta = proto_register_protocol("JXTA Message", "JXTA Message", "jxta.message"); - register_dissector("jxta.udp", dissect_jxta_udp, proto_jxta); - register_dissector("jxta.stream", dissect_jxta_stream, proto_jxta); + jxta_udp_handle = register_dissector("jxta.udp", dissect_jxta_udp, proto_jxta); + stream_jxta_handle = register_dissector("jxta.stream", dissect_jxta_stream, proto_jxta); /* Register header fields */ proto_register_field_array(proto_jxta, hf, array_length(hf)); @@ -2389,7 +2389,6 @@ void proto_reg_handoff_jxta(void) if(!init_done) { message_jxta_handle = create_dissector_handle(dissect_jxta_message, proto_message_jxta); - stream_jxta_handle = find_dissector("jxta.stream"); media_type_dissector_table = find_dissector_table("media_type"); ssl_handle = find_dissector_add_dependency("ssl", proto_jxta); -- cgit v1.2.3